On Sun, 2007-02-04 at 07:27 -0800, Tom Phoenix wrote: > On 2/3/07, Mathew Snyder <[EMAIL PROTECTED]> wrote: > > > my @date = (localtime)[3..5]; > > my $day = sprintf '%02d', $date[0] - 1; > > my $month = sprintf '%02d', $date[1] + 1; > > You shouldn't have to do arithmetic on the date components, including > all that mess about how many days are in a month. That's hard to get > right; besides, somebody else has debugged all that already. Do the > arithmetic on the time, instead, and you'll have the right date: > > my @date = (localtime (time - 24*60*60) )[3..5]; # 24 hours ago > was yesterday >
I use this for exactly that problem. I have to go 6:00am yesterday to 6:00am today in DB2. I hardcoded the 6:00 and used strftime to format the date component. http://perldoc.perl.org/functions/localtime.html -- Ken Foskey FOSS developer -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/