Zetect Expressions & Transforms Back to zetect.inSwitch portal ⇄

Date Transforms

Reformat dates, shift them by days, months or years, convert raw timestamps, and get the current date. A date that can't be read makes the transform return no value, so the attribute is not sent.

Date patterns

The sourceFormat, targetFormat and format options take Java date patterns. Put literal text in single quotes.

LettersMeaningExample
yyyyYear2026
MMMonth number03
ddDay of the month15
HH:mm:ssHours (00–23), minutes, seconds09:30:00
XTime zone offset, such as Z or +05. When reading, the offset is accepted but ignored: the time is not converted.Z
'T', 'Z'Literal textT

Pattern letters are case-sensitive: MM is the month and mm is minutes. An invalid pattern makes the transform return no value.

How dates are read

sourceFormatInput it reads
Not setAn ISO date such as 2026-03-15, or an ISO date and time without an offset such as 2026-03-15T09:30:00. A value with Z or an offset needs a sourceFormat.
A patternA date and time in that pattern. A pattern with no time, such as dd/MM/yyyy, reads a date at midnight.
windows-filetimeA Windows file time: a whole number of 100-nanosecond intervals since 1 January 1601, read as UTC. Directories store timestamps such as lastLogonTimestamp and pwdLastSet this way.
epoch-secondsA whole number of seconds since 1 January 1970, read as UTC.
epoch-millisA whole number of milliseconds since 1 January 1970, read as UTC.

The three timestamp names are not case-sensitive. Without a targetFormat, results are written in ISO form such as 2026-04-15T00:00. Seconds are left out when they are zero.

date-format

Reads a date and writes it in another format. Returns no value when the input is missing, blank or can't be read.

OptionDescriptionDefault
inputThe date to reformat.The previous step's result in a pipeline; otherwise none
sourceFormatThe pattern the input is in, or windows-filetime, epoch-seconds or epoch-millis.ISO date or date and time
targetFormatThe pattern to write.ISO date and time
{ "type": "date-format", "input": "${hireDate}",
  "sourceFormat": "yyyy-MM-dd'T'HH:mm:ssX", "targetFormat": "dd/MM/yyyy" }
2024-03-15T09:30:00Z → 15/03/2024

{ "type": "date-format", "input": "${startDate}",
  "sourceFormat": "dd/MM/yyyy", "targetFormat": "yyyy-MM-dd" }
15/03/2024 → 2024-03-15

{ "type": "date-format", "input": "${hireDate}" }
2026-01-15 → 2026-01-15T00:00

{ "type": "date-format", "input": "${lastLogonTimestamp}",
  "sourceFormat": "windows-filetime", "targetFormat": "yyyy-MM-dd'T'HH:mm:ss'Z'" }
133500000000000000 → 2024-01-17T21:20:00Z

{ "type": "date-format", "input": "${createdAt}",
  "sourceFormat": "epoch-seconds", "targetFormat": "yyyy-MM-dd" }
1767225600 → 2026-01-01

date-add

Reads a date, adds days, then months, then years, and writes the result. Use negative numbers to subtract. When a month is too short for the day, the last day of the month is used. Returns no value when the input is missing, blank or can't be read.

OptionDescriptionDefault
inputThe starting date.The previous step's result in a pipeline; otherwise none
sourceFormatThe pattern the input is in, or windows-filetime, epoch-seconds or epoch-millis.ISO date or date and time
daysWhole number of days to add.0
monthsWhole number of months to add.0
yearsWhole number of years to add.0
targetFormatThe pattern to write.The sourceFormat; ISO date and time if neither is set
{ "type": "date-add", "input": "${hireDate}", "sourceFormat": "yyyy-MM-dd", "days": 90 }
2026-01-15 → 2026-04-15

{ "type": "date-add", "input": "${hireDate}", "days": 90 }
2026-01-15 → 2026-04-15T00:00

{ "type": "date-add", "input": "${startDate}", "sourceFormat": "yyyy-MM-dd", "months": 1 }
2026-01-31 → 2026-02-28

{ "type": "date-add", "input": "${createdAt}", "sourceFormat": "epoch-seconds",
  "days": 30, "targetFormat": "yyyy-MM-dd" }
1767225600 → 2026-01-31

current-date

Returns the date and time when the transform runs, in the Zetect server's time zone. It takes no input and ignores the previous step's result.

OptionDescriptionDefault
formatThe pattern to write.ISO date and time, with fractions of a second
{ "type": "current-date", "format": "yyyy-MM-dd" }
→ 2026-11-14

{ "type": "current-date" }
→ 2026-11-14T10:22:31.572158900