Oct 22, 2018 09:00 PM
Hey there, Airtable Experts…
I have created a simple task table where I am attempting to use a formula field to automatically categorize individual tasks based on their due dates, i.e., Overdue, Due Today, Due Soon (2 days or less), etc. I have used the following formula:
IF(DATETIME_DIFF({Due Date}, NOW(), 'days') < 0, "1. Overdue", IF(DATETIME_DIFF({Due Date}, NOW(), 'days') = 0, "2. Today", IF(DATETIME_DIFF({Due Date}, NOW(), 'days') <= 2, "3. Due Soon (2 days or less)", IF(DATETIME_DIFF({Due Date}, NOW(), 'days') <= 7, "4. Upcoming (7 days or less)", IF(DATETIME_DIFF({Due Date}, NOW(), 'days') > 7, "5. Future", BLANK())))))
The challenge I’m having is that the calculated difference between the due date and the current date yields the incorrect category, i.e., items due today are showing as overdue, and items showing due tomorrow are showing as due today. This leads me to believe the timezone is incorrect.
I have tried swapping NOW() for TODAY(), but that only yields the same result.
Anyone have any idea what the issue may be and how to correct it?
Many thanks for your help!
Oct 22, 2018 09:19 PM
Try enabling the “Use same Timezone for all users” option only on the formula field (not on the date field).
Oct 22, 2018 09:25 PM
Thanks, @Jeremy_Oglesby, but I do not see that option in the Formula field anywhere, presumably because the output options for that field are not dates but text (e.g., “2. Today”).
Oct 22, 2018 09:34 PM
Doh… :roll_eyes: I didn’t think that one through
Oct 23, 2018 04:02 AM
But there is a date in the Formula, that field has the option checked on?
Oct 23, 2018 11:36 AM
There’s no option, and I believe that option is only available if the output from the formula is a date.
Oct 23, 2018 11:47 AM
This is kind of a round-about, hackey way to do this, but it may serve to verify what’s going on…
Try creating another formula field called “Today” with this formula:
DATETIME_FORMAT(
TODAY(),
'l'
)
And check to see that it returns the correct date.
Then try modifying it to:
DATETIME_FORMAT(
SET_TIMEZONE(
TODAY(),
'<your timezone>'
),
'l'
)
And see if it is still accurate. Try using that field as a go-between and reference it in your formula above and see if it changes anything.
Oct 23, 2018 11:50 AM
Yeah timezones in airtable are fairly tricky and often screw up my filters as well, I wish there were better options for controlling them. In situations like this where local times and UTC times are getting confused in formulas & filters, I’ve used some of W_Van_Hall’s advice in using SET_TIMEZONE to slide times around to match your local timezone in which you are trying to have your filters apply. Something like:
Oct 23, 2018 12:27 PM
I’m not talking about the Formula, but about {Due Date}
field.
Oct 23, 2018 09:01 PM
Brilliant! This has fixed the issue. Thanks, @Jeremy_Oglesby!
Now the question becomes: why in the world is Airtable setting my timezone as UTC?