##############
##############
###
###      FUNCTION NAME
###      ----------
###      DateMinusX()
###
###      PURPOSE:
###      --------
###      Return a date that is X number of days ago
###
###      RETURN VALUE:                    Comment:
###      ---------------------------------------------------------------------------
###      A date that is X number of days ago 
###
##############
##############
sub DateMinusX
{
    my($offset) = @_;
    my($sec, $min, $hour, $mday, $mon, $year, $wday, $yday);
    ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) =
        localtime((time-(86400*$offset)));
        $mon = $mon+1;
        $year = $year+1900;
        return "$mon/${mday}/$year";
}
 
usage:
 
 $BeginDate  = &DateMinusX(7); // returns a date/time that is 7 days ago
 $EndDate  = &DateMinusX(1); // returns a date/time that is 1 day ago
 
-Ron

________________________________

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Tue 8/17/2004 12:50 PM
To: [EMAIL PROTECTED]
Subject: date calculations



All,

If I wanted to subtract 1 from a date on the 1st of any month what module
will reflect the correct date?  For example, system time is 09.01.04 and I
want data from 08.31.04, I would have to subtract 1 day.  Which module do
I need to install?

thanks,
derek



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to