On Jan 9, Scott Taylor said: >Can anyone tell me how I can set a variable to a date, then subtract x >number of days from it and output the new date? I can't seem to find it >anywhere.
You should use a date manipulation module, such as Date::Calc or Date::Manip, or the standard Time::Local or POSIX modules. POSIX offers the mktime() function, which acts like Time::Local's timelocal() function. use POSIX 'mktime'; my $days = 100; my $date = mktime(0,0,12, 0,9,102); # 12:00:00 on 1/9/2002 my $newdate = $date - ($days * 86400); To get a readable format from $date and $newdate, use the localtime() function (built-in): my $today = localtime $date; or the strftime() function from POSIX: use POSIX 'strftime'; my $then = strftime("%D", localtime($newdate)); # %D is %m/%d/%y # %m: 01 - 12; %d: 01 - 31; %y: 00 - 99 -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]