Docly Developers
ExampleUpdated 24 Oct 2026

Compare date field with todays date

Some examples on comparing date fields. Note: the comparison is made once, when the page is rendered, and the cached result is served after that. Compare against today's date in an API function if the answer must be current.

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 2026-11-02.

Then we compare the strings, is 2026-11-02 same as 2001-01-01?

No, it is not today.