Have you installed and DATE::CALC. If so you would do something like this:

# use date calc and get the current time into a hash:

use Date::Calc  qw(:all);

my %th;

@th{qw(sec min hour mday mon year wday yday isdst)} = localtime(time);

$th{mon}++;
$th{year} += 1900;

#define the expiatory date (you have to do this for your purpose.

my @expiatory = qw(2002 1 23);

#here's the function you're looking for
#it is a Date::Calc function:

my $dd = Delta_Days(@th{year, mon, mday}, @expiatory);

#print out the difference in days.

print "$dd\n";

You'll have to install Date::Calc and read perldoc Date::Calc to get
familiar with it, but it is a VERY good module for working with dates in any
way I've ever needed to work with them. Delta_Days is only one useful
function it contains. There are numerous others you should be familiar with.

You don't have to use a hash like I did with the localtime function, I just
like working with the hash slices. Customize that to your purpose.

Hope this helps,

Steve Howard

-----Original Message-----
From: Ackim Chisha [mailto:[EMAIL PROTECTED]]
Sent: Sunday, July 22, 2001 8:50 AM
To: [EMAIL PROTECTED]
Subject: Dates subtraction


Hi Everybody,
Is there a shortcut way to subtract dates say for instance I would like to
be subtracting the current date from the date that the service for  a
particular user expires, say (expiry date -- current date). Or do I have to
write
a specific script for this. Forgive my newbie ignorance.

Kregards,
Ackim.



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

Reply via email to