Rory Oconnor wrote:
> 
> Can anyone think of a good way for me to find out what the date of last
> sunday is with perl?  I'm writing a script that will need to do some
> basic reporting starting from the previous sunday.
> 
> I'm usign the date format YYYY-MM-DD

$ perl -le'use Time::Local;
( $year, $mon, $day ) = split /-/, "2002-03-21";

@date = localtime timelocal( 0, 0, 0, $day, $mon - 1, $year - 1900 );
printf "%04d-%02d-%02d\n", $date[5]+1900, $date[4]+1, $date[3];

@date = localtime timelocal( 0, 0, 0, $date[3] - $date[6], @date[4,5] );
printf "%04d-%02d-%02d\n", $date[5]+1900, $date[4]+1, $date[3];
'
2002-03-21
2002-03-17



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to