825 Views 2 Replies Latest reply: Mar 3, 2009 2:23 PM by BenChase
When you subtract two dates, the result is the difference in seconds. There are built-in constants for the number of seconds in various time elements, such as hours and days, so you can subtract one date from the other and divide by the days constant (or the number of seconds in a day) to get the number of days.
font-family: Monaco, 'Courier New', Courier, monospace;
border: 1px solid #000000;
title="this text can be pasted into the Script Editor">
property NumDays : 5
set DateNow to (current date)
set FilterTime to (NumDays * days) -- the number of seconds
set TheFIle to (choose file)
tell application "Finder"
set FileModDate to modification date of TheFIle
log "modification date: " & FileModDate
set TimeDiff to (DateNow - FileModDate) -- the difference in seconds
if TimeDiff ≥ FilterTime then
set DaysOut to (TimeDiff div days) -- the number of days