date()
Converts the string to date type.
Syntax
date(DATE_EXPR, DATE_FMT, [LOCALE])
Required Parameter
DATE_EXPR
- Source string expression to be converted to date type.
DATE_FMT
- Pattern letters to specify the date and time format.
Units of time Description Example G
BC/AD AD
y
Year 1996
;96
M
Month July
;Jul
;07
w
Week of the year 27
W
Week of the month 2
d
Day of the year 189
D
Day of the month 10
F
Day of week number 2
E
Day of the week Tuesday
;Tue
u
Number of the day of the week(1=Monday, ..., 7=Sunday) 1
a
AM/PM PM
H
Hour(0-23) 0
k
Hour(1-24) 24
K
AM/PM Hour starting with 0 (0-11) 0
h
AM/PM Hour starting with 1(1-12) 12
m
Minute 30
s
Second 55
S
Millisecond 978
z
Time zone Pacific Standard Time
;PST
Z
Time zone(RFC 822) -0800
X
Time zone(ISO 8601) -08
;-0800
;08:00
Optional Parameter
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