I want to set a time range for dates with yymmdd format. I want to be able to set a starting and ending date and run a for loop that will increase the date each time through the loop. Most of the information I have found is for 8 digit dates. How can I do this using only six? My code follows this rough outline
$start_date = $start_year, $start_month, $start_day;
$end_date = $end_year, $end_month, $end_day;
For ($filename = $start_date, $name; $start_date <= $end_date; $start_date->add(days=>1))[
open(FILE, ¡¥<$filename.txt¡¨); # Files look like this ----> 080518_name.txt
#do stuff w/file
#continue until last file in date span
}
I'm having trouble formatting the dates to look just like this "080623" without spaces, symbols or date/time. How can I do this? How do I set the date to increase the day (and month and year as necessary)?
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.