WEEKDAY() shows same day for 2 different dates

Hello,

I’m using WEEKDAY() to show me which day of the week (Jour (#)) an order came through.
For some reason, the formula shows me this :

Orders with different dates 15/04 and 14/04 shouldn’t show the same Day Number in Jour (#) which is where WEEKDAY() is applied.

I know it’s related to the fact that these orders came between 00:00 and 02:00 am, tho I don’t know how to resolve this.

Any idea ?

Thanks

Welcome to the community, @MatthieuB! :smiley: Airtable stores dates internally relative to GMT. Even if you set a date field to not display using GMT, the GMT data is still what’s used for calculations. If you don’t live in the GMT timezone, the actual change from one day to another won’t match your local time. For me—PDT in the US, which is currently GMT-8—the shift happens late in the afternoon.

Screen Shot 2021-04-15 at 6.11.20 AM

To get an accurate representation, you’ll need to use DATEADD() to manually shift the time based on your local offset from GMT before doing the WEEKDAY() calculation. For me, the formula looks like this:

WEEKDAY(DATEADD(date, -8, "hours"))

Screen Shot 2021-04-15 at 6.14.28 AM

1 Like

Another option is to use the SET_TIMEZONE function inside of DATETIME_FORMAT

DATETIME_FORMAT(
  SET_TIMEZONE({Created at}, 'Australia/Sydney'), 
  'e'
)

If you want the day of the week as a number, you will need to wrap the formula in VALUE. On the other hand, if you want the day of the week in words, you can use a different format specifier, such as 'dddd'.

One advantage of this method is that you do not have to worry if your offset from GMT sometimes changes due to daylight savings time.

All of these functions are documented in the formula field reference.

4 Likes

This topic was solved and automatically closed 3 days after the last reply. New replies are no longer allowed.