Comparing dates

i need to compare 2 dates and get the difference between them, so i can add/substract it from other dates (i’m writing a script that will reset the dates on images if the date was wrong on the camera, by setting the new date for 1 image, then the rest get set automatically) any ideas how to do that? or how to convert a date into a number and back so it can be done by simple math?

Hi,

If you just subtract the variables you get the difference in seconds:

set theNow to current date
set theThen to date "Saturday, January 1, 2005 00:00:00"
set mySeconds to theNow - theThen
display dialog "This year is " & mySeconds & " seconds old."

You may find these links handy:
http://developer.apple.com/documentation/AppleScript/Conceptual/AppleScriptLangGuide/AppleScript.2d.html
http://developer.apple.com/documentation/AppleScript/Conceptual/AppleScriptLangGuide/AppleScript.ab.html

Best wishes

John M

thanks, that’s exactly what i needed. :slight_smile: