in reply to Re: Re: Date::Manip Help
in thread Date::Manip Help
The reason you were only getting 267 records is because your inner loop only executed 89 times:#!/usr/bin/perl # get current Date from MySql use warnings; use strict; use Date::Manip; + my @city=("C","K","D"); my $j; for ($j=0;$j<3;$j++) { my $date= ParseDate("today"); + my $i; + # either start from 0, or use <= for ($i=1;$i<=90;$i++) { $date= DateCalc($date, "+ 1 day"); $date= UnixDate($date, '%Y-%m-%d'); print "Date: $date, city: $city[$j]\n"; } }
You either need to initialize $i to 0 or change the conditional expression to $i <= 90.for ($i=1;$i<90;$i++)
Hope this helps,#!/usr/bin/perl # get current Date from MySql use warnings; use strict; use Date::Manip; + my @city=("C","K","D"); + my $date= ParseDate("today"); + # using a Perl-style (not C-style) loop helps prevent # the error seen in the earlier loop construct for my $i ( 1 .. 90 ) { $date= DateCalc($date, "+ 1 day"); $date= UnixDate($date, '%Y-%m-%d'); + for my $j ( 0 .. 2 ) { print "Date: $date, city: $city[$j]\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Date::Manip Help
by Agyeya (Hermit) on May 12, 2004 at 04:38 UTC |