Time Comparisons


silogarrett

Recommended Posts

Hello Guru!

I need to compare the time elapsed between a day/month/year in the past, to the current day/month/year, to ascertain the years in decimal form - that is:

29/04/2008 to today, 29/08/2011 = 3.3342 years.

Is the a way to state a date in decimal form, so that one could do addition or subtraction on two dates?

Mike

Link to comment
Share on other sites

I think what you want is the strToTime() function. See section 4.12.11 in the user's guide. Its pretty self explanatory. You could also, technically, parse the date into its component year, month, and day parts, then use hms formatting (section 4.9) with evaluate(), but strToTime() is much easier and cleaner. Note that the result is in seconds since 1970, so you'll need to divide the difference by the number of seconds in a year. I'll let you determine how you want to deal with leap years.

Link to comment
Share on other sites

  • 3 months later...

Archived

This topic is now archived and is closed to further replies.