Calculating the number of days to complete a task?

I would like to see how many days are left before a task or a project is due. Instead of a list of due dates, I would like to see a calculation of the due date minus today’s date to give the number of days, weeks, or months until that item is due. Forecast has a number of options for viewing the Gantt, but it’s not quite what I’m looking for. I would appreciate any suggestions if I’ve missed something obvious or ideas any of you may have for a workaround. Cheers,

1 Like

AppleScript is your friend for this. Here is an example that will pull tasks from Forecast in to a list with days until due, project name, and task name.

on run {}
	set ActionList to {}
	set theDateToday to the (current date)
	tell application "OmniFocus"
		-- get Forecast perspective list
		tell front document window of default document to set its perspective name to "Forecast"
		tell content of front document window of default document to ¬
			set TreeList to (value of every leaf)
		-- transfer the action items into readable form
		repeat with ListItem in TreeList
			if (due date of ListItem is not missing value) then
				set theOFDue to due date of ListItem
				tell application "Finder" to set theDueDays to (theOFDue - theDateToday) / (60 * 60 * 24) as integer
				set end of ActionList to {td:(theDueDays), tp:name of containing project of ListItem, tn:name of ListItem}
			end if
		end repeat
	end tell
end run


1 Like

Wow. JJW, thank you. I was not expecting such a quick response–and one with an applescript! Thank you for your time. I tested the script and returned this error:

error “OmniFocus got an error: Can’t get name of containing project of inbox task id “gY3ouIU6VtE” of document id “dDJBPcwoyqd”.” number -1728 from name of containing project of inbox task id “gY3ouIU6VtE” of document id “dDJBPcwoyqd”

I should also add that in order to keep my task list from becoming overwhelming, I tend to use ‘defer dates’ more than I do ‘due dates’. How might that be incorporated into the script? Thanks again.

I think Inbox items have no containing project. You might remove the tp: name of containing project of ListItem as a list item to ActionList and try again.

I think you can simply change it this way …

if (defer date of ... ) then
    set theOFDue to defer date of ListItem

I had this script segment handy because I use it as part of a longer script to report my task lists thru GeekTool.