JSONata for dates and timestamps
Format today
To format the current date and time in a custom format, you can use the $moment().format() function.
Format today to return:
Copy
$moment().format('YYYY-MM')
Result: 2025-12
To include a timestamp:
Copy
$moment().format("YYYYMMDD_hhmmss")
Result: 20240708_043210
Current week number
To find out the current week of the year, use:
Copy
$moment().week()
This returns the month of the year where January is 0 and December is 11.
Year and Month
To combine the current year and month in a custom format, you can use:
Copy
$moment().year() & "_" & $moment().month()
Result: 2024_6
Today plus 1 day
Copy
$moment().add(1,'day').format('YYYY-MM-DD')
Tip: Many nodes in OL Connect Automate accept JSONata expressions. For sample expressions, see JSONata expression samples