date()

Converts the string to date type.

Syntax

date(DATE_EXPR, DATE_FMT, [LOCALE])
Required Parameters
DATE_EXPR
Source string expression to be converted to date type.
DATE_FMT
Pattern letters to specify the date and time format.
Units of timeDescriptionExample
GBC/ADAD
yYear1996; 96
MMonthJuly; Jul; 07
wWeek of the year27
WWeek of the month2
dDay of the year189
DDay of the month10
FDay of week number2
EDay of the weekTuesday; Tue
uNumber of the day of the week(1=Monday, ..., 7=Sunday)1
aAM/PMPM
HHour(0-23)0
kHour(1-24)24
KAM/PM Hour starting with 0 (0-11)0
hAM/PM Hour starting with 1(1-12)12
mMinute30
sSecond55
SMillisecond978
zTime zonePacific Standard Time; PST
ZTime zone(RFC 822)-0800
XTime zone(ISO 8601)-08;-0800;08:00
Optional Parameters
LOCALE
A 2-digit or 3-digit code locale specified by ISO 639. If you do not specify the locale, it is set to en. For the ISO 639 locale code, refer to the following link: https://iso639-3.sil.org/code_tables/639/.

Description

If the DATE_EXPR is null or an empty string, it returns null. If it is a type other than a string, it attempts to convert the date after automatically converting it to a string.

Usage

json "{}"
| eval date=date("2013-06-10 00:30:55.978", "yyyy-MM-dd HH:mm:ss.SSS")
=> 2013-06-10 00:30:55+0900

json "{}"
| eval date=date("2020-01-30T10:11:12.123Z", "yyyy-MM-dd'T'HH:mm:ss.SSSX")
=> 2020-01-30 19:11:12+0900

json "{}"
| eval date=date("6월 1 2020 12:34:56", "MMM dd yyyy HH:mm:ss", "ko")
=> 2020-06-01 12:34:56+0900