N8n works bad with Notion date-based formulas — "Get all" filtering (secretly) iimplements timezone

I need to generate Notion employee records on daily basis. I use a date formula formatting “17-07-2022”. Then I suck this data in n8n, applying filter for this date property

Everything went well before I tested I at night, right after midnight. I created records, but n8n found nothing. But if I set filter on yesterday, n8n accepted it. When I created new records in the morning at 11-22 AM, n8n recognized them as today.

So in Notion formulas, if it involves dates, it might looks different for users and for n8n. And this is bad for “Get all”. While I see one formatted date, like 17-07-2022, n8n sees 16-07-2022.

And it can’t be fixed with a timezone setting in n8n, because I pass a string and have no timezone setting in the Notion node.
image

Hi @artildo, I am not quite sure which behaviour you’re expecting and how your workflow currently looks like.

I quickly tested this and specifying a time zone (using an ISO timestamp) worked fine using the Notion node:

The one row/page matching the timestamps used in the node is working fine, despite using a different time zone than the n8n timestamp is in (Notion uses 10:31 Europe/Berlin, n8n used 08:30 UTC to 08:32 UTC in this example).

So it would be great if you could elaborate a bit here.

@MutedJam Well, I’m talking about other thing.

You should test not a Date property in Notion. The problem is in Formula properties, which use some date formulas inside. Let me show you.

So I want n8n to get today’s records. It can’t be done straightforward because Notion offers limited date formats (it has no “DD-MM-YYYY” format). Moreover, for “created time” props you can’t change the format at all.

So I have to add a formula property, format the date the way I need (DD-MM-YYYY).

This formula could be formatDate(prop("created at"), "DD-MM-YYYY")

In n8n the Notion node compares this prop with a string, let’s say, 18-07-2022.

So I have a record where I see the formatted date 18-07-2022 and created at 0:35. I launch n8n with manual filter on this prop against “18-07-2022”.

I expect: see this record as the result
I receive: empty

This is completely countrintuitive.

Why it happens? I guess, when n8n Notion node applies manual filter against Formulas based on dates, it takes into accound some Notion timezone settings. And they might tell: “well, from our point of view, this is still yesterday.”

This could be fixed, if the n8n Notion node manual filtering neglected Notion timezone settings.

Thanks @artildo. Could you share how exactly your formula field looks like in Notion and share your Notion node querying data based on this field?

Hi, @MutedJam

I haven’t manage to replicate it with an arbitrary date field as a source. But with a “created date” the bug works.
I leave the page with the code: Notion – The all-in-one workspace for your notes, tasks, wikis, and databases.

So the page was created on 27.07.2022 at 0:06 AM. I want to retieve this page based on this date.
I fornat the date to have YYYY-MM-DD and get 2022-07-27.

I pass this condition as a text string, it returns notihing. It works if I pass 2022-07-26 though.

Hi @artildo, with your example I am able to better understand the situation, thanks so much for that! I don’t think this is something that can be handled transparently by the trigger node though.

You can, however, create a string respecting the time zone in n8n though. If you have an ISO timestamp for example, an expression returning the date in a given time zone could look like so:

{{ DateTime.fromISO('2022-08-05T22:42:00+02:00').setZone("Asia/Seoul").toFormat('yyyy-MM-dd') }}

This expression takes an ISO timestamp on 2022-08-05 and will return the date in the Asia/Seoul time zone, resulting in 2022-08-06 to be returned in the above example.

This also works dynamically:

Thak you for the reply. Now I use only hard-printed date lines to avoid any issues with timezones.

How do you hard print the dates?

I have been trying to figure out this date thing and when the strings match in n8n still the if node puts everything on the false…