Hello Corion, Earlier I received a piece of code in part like this:

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11152433 use warnings; use Time::Piece; use Time::Seconds; { print "MONTH is first, then DAY. That is: MM/DD/YYYY\n"; @ARGV = '05/01/2023'; # MONTH comes first my $t = Time::Piece->strptime("$ARGV[0] 12", "%m/%d/%Y %H"); my $daybefore = ($t - ONE_DAY)->mdy("/"); printf <<END, $ARGV[0], $daybefore; Date as supplied: %s Date minus one day: %s END }
download Outputs: MONTH is first, then DAY. That is: MM/DD/YYYY Date as supplied: 05/01/2023 Date minus one day: 04/30/2023

As I attempted to comment before, this works perfectly but I don't have the luxury of manually entering the date as shown. (@ARGV = '05/01/2023';) My script provides the date in a string. From there I need the script to provide "the day before" in a different string. (At least that is the plan) When I attempt to use the string within the above code I cannot get it to work, I guess primarily because I don't understand Time::Piece well at all.


In reply to Re^6: The day before a specific date by jpys
in thread The day before a specific date by jpys

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.