Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: calculate time(days)

by moodster (Hermit)
on Apr 04, 2002 at 17:08 UTC ( #156707=note: print w/replies, xml ) Need Help??


in reply to calculate time(days)

Given that you've supplied almost no background information whatsoever, I'd say that you have several options.

If you have two perl scalars with strings representing dates you could go with the various Decode_Date_XX functions of Date::Calc, calculate the number of days each date represent (Date_to_Days) and compare these values. This is all covered in perldoc Date::Calc

There are several date manipulation modules to choose from on CPAN, but Date::Calc is one of the most popular. You might want to look into Date::Simple as well.

If your data is stored in a database you may be able to do the comparison on the database level, depending on what database flavor you are using. For example, MS SQL will let you subtract one date from another calculate the difference in days. The SQL for calculating the number of days between the START and STOP values for all rows in the EXAMPLE table looks something like this:

SELECT STOP - START FROM EXAMPLE

Cheers,
--Moodster

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://156707]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2022-12-01 12:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?