Compare date field with todays date Last updated: 08. Dec 2022

Some examples on comparing date fields.

Example

Data

{
    "DateField1" : "2001-01-01"
}

Code Compare-dates.hash

First we format the dates with "yyyy-MM-dd" format.
#var today = docly.format(new Date(), "yyyy-MM-dd")#
Today is #today#.

Then we compare the strings, is #today# same as #DateField1#?

#if (DateField1==today) {#
Yes, it is today.
#} else {#
No, it is not today.
#}#

Output

First we format the dates with "yyyy-MM-dd" format.
Today is 2024-04-25.

Then we compare the strings, is 2024-04-25 same as 2001-01-01?

No, it is not today.