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])
Required Parameters
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 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

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

AbbreviationGMT offsetDescription
UTCGMT+0Coordinated Universal Time
KSTGMT+9Korea Standard Time
CESTGMT+2Central European Summer Time
MSKGMT+3Moscow Standard Time
PSTGMT-7Pacific Standard Time
ESTGMT-5US Eastern Standard Time
TIMEZONE

You can provide the time zone in the form of GMT+09, GMT+0900, GMT+09:00, or GMT+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"