View Single Post
Quote:
Originally Posted by back2fala View Post
Hi, I am trying to get the number of tasks done today in applescript. This is my code:

Code:
completion date is equal to dateToday)
This return zero even though it shouldn't.
I can see why one might expect this to work - it's easy to forget that Applescript dates have a time component.

The time-stamp in your dateToday will be that of the instant at which the code is run. The time-stamps in your completed actions will be those of the moments of completion.

Thus, of course, no match ...

The simplest fix might look something like:

Code:
set dateToday to current date

-- STRIP THE TIME BACK TO 00:00 HOURS
set dateToday to dateToday - (time of dateToday)

tell application "OmniFocus"
	tell front document
		-- (SINCE 00:00 HRS THIS MORNING ...)
		set tasksDoneToday to a reference to (flattened tasks where completion date > dateToday) 
		display dialog (count of tasksDoneToday)
	end tell
end tell
--