Drieux wrote: > > On Tuesday, May 28, 2002, at 09:25 , Sven Bentlage wrote: > > > I'm trying to get all the date values for the week (7days) ahead of a > > specified date. > > To get the current date I use : > > my ($d, $m, $y) = (localtime)[3,4,5]; > > my $date = sprintf("%02d-%02d-%02d", $d, $m+1, $y-100); ^^^^^^
> > To get the date of the date 7 days ahead I use: > > my ($da, $ma, $ya) = (localtime (time+ (7*24*60*60)))[3,4,5]; > > my $next_date = sprintf("%02d-%02d-%02d", $da, $ma+1, $ya-100); ^^^^^^^ You shouldn't subtract 100 from the year returned from localtime, it won't work with all dates, use modulus instead. $year % 100 > your friend the loop would help here. > > use constant SECONDS_PER_DAY (24*60*60); > > my $day_ahead = 1; > my $max_day_ahead = 7; > > for (; $day_ahead <= $max_day_ahead ; $day_ahead++ ) > { > my $tmp_t =( $day_ahead * SECONDS_PER_DAY); > my ($da, $ma, $ya) = (localtime(time + $tmp_t))[3,4,5]; > my $next_date = sprintf("%02d-%02d-%02d", $da, $ma+1, $ya-100); > .... > } use POSIX 'strftime'; print strftime '%d-%m-%y%n', localtime time + $_ * 86_400 for 0 .. 6; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]