Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: calculate time(days)

by moodster (Hermit)
on Apr 04, 2002 at 17:08 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-23 23:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found