Function for yesterday?

I have an global variable that stores as the following date/timestamp example:
April 1, 2022 12:57 PM

I'm pretty sure this maps to LLL in the Date/Time Formatter Node

What I'd like to do is be able to have a function node that would change based on that global variable being yesterday or not.

So pseduocode

if global.get('mailbox') = yesterday 
{ do X }
else 
{ do Y }
const date = new Date()
const yesterday = date.setDate(date.getDate() - 1)

Though that might not do exactly what you expect since that calculation returns a timestamp 24 hours ago (give or take issues with DST). Depends whether you want to compare against any time yesterday or simply any time over 24 hours ago.

If you need to set yesterday to "00:00" in order to compare against any time yesterday, you could change to something like:

const date = new Date()
const yesterday = date.setDate(date.getDate() - 1)
yesterday.setTime(00,00)

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