string()
Either converts an arbitrary expression to a string, or converts a date to a string in specified date format.
Syntax
string(EXPR)
string(DATE_EXPR, DATE_FMT[, LOCALE])
string(DATE_EXPR, DATE_FMT[, TIMEZONE])
str(EXPR)
str(DATE_EXPR, DATE_FMT[, LOCALE])
str(DATE_EXPR, DATE_FMT[, TIMEZONE])
string(DATE_EXPR, DATE_FMT[, LOCALE])
string(DATE_EXPR, DATE_FMT[, TIMEZONE])
str(EXPR)
str(DATE_EXPR, DATE_FMT[, LOCALE])
str(DATE_EXPR, DATE_FMT[, TIMEZONE])
Required Parameter
EXPR
- Expression that returns the value to be converted to a string
DATE_EXPR
- Source string expression to be converted to date type
DATE_FMT
- Define the format to use to parse strings using the same pattern letters as the ones used in
date()
.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
-
Alphabetical abbreviations of time zones are also supported, but note that they can have ambiguous meanings. For example,
CST
may be Chinese Standard Time, or US Central Standard Time or Cuban Standard Time. If you do not specify a time zone, the time zone according to the locale of the system where Logpresso is installed is used. For information on time zone abbreviations, refer to Time Zone Abbreviations – Worldwide List at the following address: https://www.timeanddate.com/time/zones/ -
Examples of time zone abbreviations
Abbreviation GMT offset Description UTC GMT+0 Coordinated Universal Time KST GMT+9 Korea Standard Time CEST GMT+2 Central European Summer Time MSK GMT+3 Moscow Standard Time PST GMT-7 Pacific Standard Time EST GMT-5 US Eastern Standard Time TIMEZONE
-
You can provide the time zone in the form of
GMT+09
,GMT+0900
,GMT+09:00
, orGMT+9:00
.
Usage
json "{}" | eval str=string(1) => "1"
json "{}" | eval str=string(1.2) => "1.2"
json "{}" | eval str=string(true) => "true"
json "{}" | eval str=string(null) => null
json "{}" | eval str=string(now(),"yyyyMMddHHmmss") => "20140807164417"
json "{}"
| eval
str=string(date("20170329","yyyyMMdd"),"yyyy-MM-dd HH:mm:ssZ","GMT+08")
=> "2017-03-28 23:00:00+0800"