Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculating dates in perl

Status
Not open for further replies.

Milamber

ISP
Jun 15, 1999
31
US
Hi everyone,<br>
<br>
I'm currently involved in a report generating project, where my perl script has to work out how many days, hours and/or minutes the difference in two dates is.<br>
<br>
Has anyone done any similar work, and if so, do you have any code you are willing to share?<br>
<br>
Any help will be greatly appreciated!!!<br>
<br>
Cheers,<br>
Milamber
 
Do you already have the dates? if you already have the dates, then you can just use a break command to separate days from hours from minutes, then tell it to subtract; that simple!<br>
<br>
<br>
-Robherc<br>
robherc@netzero.net
 
Yes, the dates are entered by the user, as part of a CGI script. I need to take month and year into consideration, and with months having differing lengths (28-31 days), simple subtraction won't do it accurately enough.<br>
Say one of the dates is May 20th and the other is June 3rd, the answer would obviously be 14 days. <br>
Now I need to make the script capable of handling this sort of scenario, and also correctly calulate number of hours.<br>

 
Couldn't you set up a few arrays (i.e. @jan=(1,2,3,4,5,6) @feb=(1,2,3,4,5,6) etc.) then nest them all together into one (i.e. @dates=(@jan,@feb,@mar....) )<br>
<br>
Not sure, but you can give it a try.<br>
<br>
<br>
-Robherc<br>
robherc@netzero.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top