Try something like this: my($todayMday,$todayMon,$todayYear) = (localtime)[3..5]; my($yesterMday,$yesterMon,$yesterYear) = (localtime(time - 86400))[3..5];
$todayMon++; $todayYear += 1900; $yesterMon++; $yesterYear += 1900; -----Original Message----- From: perlwannabe [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 01, 2003 10:46 PM To: [EMAIL PROTECTED] Subject: problem with date routine I have a relatively simple script that needs to get two separate dates, today's date, and yesterday's date. The dates are in mmddyy format. Everything works great on days 2 - 31 of the month, but on the first of the month yesterday's date is not correct. For example, on October 1, 2003 the variable $dateyesterday was "100003" when it needed to be 093003. Obviously, there is no 100003. Is there a way to deal with this problem on the first day of every month? Here is the script: ################## BEGIN SCRIPT ################################ my ($mday, $mon, $year) = (localtime)[3..5]; my $datetoday = sprintf ("%02d%02d%02d", ++$mon, $mday, $year-100); print ("the value of datetoday is $datetoday\n"); my ($yesterdaymday, $yesterdaymon, $yesterdayyear) = (localtime)[3..5]; my $dateyesterday = sprintf ("%02d%02d%02d", ++$yesterdaymon, $yesterdaymday-1, $yesterdayyear-100); print ("the value of datetoday is $dateyesterday\n"); ################### END SCRIPT ##################################### -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]