TIMESTAMP values are formatted and parsed using Timestamp
Format Specifiers. Timestamp format specifiers are strings that
use special characters to describe date and/or time elements in a
string representation of a timestamp.
Timestamp format specifiers are used in the following circumstances:
TimeGenerated > TIMESTAMP ( '2004-05-28 10:23:15', 'yyyy-MM-dd hh:mm:ss' )
TO_STRING(TimeGenerated, 'yyyy MMM, dd h:m:s')
TO_TIMESTAMP(Text, 'MMM ddd yyyy')
C:\>logparser "SELECT MyField FROM file.csv" -i:CSV -iTsFormat:"yyyy-MM-dd"
C:\>logparser "SELECT TimeGenerated INTO file.txt FROM System" -i:EVT -o:TSV -oTsFormat:"yyyy-MM-dd"
The following table describes the timestamp format specifiers
supported by the Log Parser SQL-Like language:
Specifier | Description | Example specifier strings | Example formats |
---|---|---|---|
y |
year, last digit (when parsing, assumed to be relative to year 2000) |
y MM dd | 4 05 28 |
yy |
year, last 2 digits (when parsing, assumed to be relative to year 2000) |
yy MM dd | 04 05 28 |
yyy |
year, last 3 digits (when parsing, assumed to be relative to year 2000) |
yyy MM dd | 004 05 28 |
yyyy |
year, 4 digits | yyyy MM dd | 2004 05 28 |
M |
month, no leading zero | yyyy-M-dd | 2004-5-28 2004-12-01 |
MM |
month, leading zero | yyyy-MM-dd | 2004-05-28 2004-12-01 |
MP |
month, leading space | yyyy-MP-dd | 2004- 5-28 2004-12-01 |
MX |
month, with or without leading zero (when parsing) month, without leading zero (when formatting) |
yyyy-MX-dd | 2004-05-28 (when parsing) 2004-5-28 2004-12-01 |
MMM |
month, 3-character abbreviation of name (1) | MMM d, yyyy | Dec 1, 2004 |
MMMM |
month, full name (1) | MMMM d, yyyy | December 1, 2004 |
d |
day, no leading zero | yyyy-MM-d | 2004-12-1 2004-05-28 |
dd |
day, leading zero | yyyy-MM-dd | 2004-12-01 2004-05-28 |
dp |
day, leading space | yyyy-MM-dp | 2004-12- 1 2004-05-28 |
dx |
day, with or without leading zero (when parsing) day, without leading zero (when formatting) |
yyyy-MM-dx | 2004-12-01 (when parsing) 2004-12-1 2004-05-28 |
ddd |
week day, 3-character abbreviation of name (1) | ddd MMMM d, yyyy | Wed December 1, 2004 |
dddd |
week day, full name (1) | dddd MMMM d, yyyy | Wednesday December 1, 2004 |
h, H |
hour, no leading zero | h:mm:ss | 3:12:05 21:04:15 |
hh, HH |
hour, leading zero | hh:mm:ss | 03:12:05 21:04:15 |
hp, HP |
hour, leading space | hp:mm:ss | 3:12:05 21:04:15 |
hx, HX |
hour, with or without leading zero (when parsing) hour, without leading zero (when formatting) |
hx:mm:ss | 03:12:05 (when parsing) 3:12:05 21:04:15 |
m |
minute, no leading zero | hh:m:ss | 21:4:15 03:12:05 |
mm |
minute, leading zero | hh:mm:ss | 21:04:15 03:12:05 |
mp |
minute, leading space | hh:mp:ss | 21: 4:15 03:12:05 |
mx |
minute, with or without leading zero (when parsing) minute, without leading zero (when formatting) |
hh:mx:ss | 21:04:15 (when parsing) 21:4:15 3:12:05 |
s |
second, no leading zero | hh:mm:ss | 03:12:5 21:04:15 |
ss |
second, leading zero | hh:mm:ss | 03:12:05 21:04:15 |
sp |
second, leading space | hh:mm:sp | 03:12: 5 21:04:15 |
sx |
second, with or without leading zero (when parsing) second, without leading zero (when formatting) |
hh:mm:ss | 03:12:05 (when parsing) 03:12:5 21:04:15 |
l |
millisecond, no leading zeroes | hh:mm:ss.l | 21:4:15.5 03:12:05.395 |
ll |
millisecond, leading zeroes | hh:mm:ss.ll | 21:04:15.005 03:12:05.395 |
lp |
millisecond, leading spaces | hh:mm:ss.lp | 21:04:15. 5 03:12:05.395 |
lx |
millisecond, with or without leading zero (when parsing) millisecond, without leading zero (when formatting) |
hh:mm:ss.lx | 21:04:15.005 (when parsing) 21:04:15.5 3:12:05.395 |
n |
nanosecond, no leading zeroes | hh:mm:ss.ll.n | 21:4:15.005.400 03:12:05.395.1900 |
nn |
nanosecond, leading zeroes | hh:mm:ss.ll.nn | 21:04:15.005.00000400 03:12:05.395.001900 |
np |
nanosecond, leading spaces | hh:mm:ss.ll.np | 21:04:15.005. 400 03:12:05.395. 1900 |
nx |
nanosecond, with or without leading zero (when parsing) nanosecond, without leading zero (when formatting) |
hh:mm:ss.ll.nx | 21:04:15.005.00000400 (when parsing) 21:04:15.005.400 3:12:05.395.1900 |
tt |
AM/PM notation | hh:mm:ss tt | 09:04:15 PM 03:12.05 AM |
? |
any character (when parsing) space (when formatting) |
yyyy-MM-dd?hh:mm:ss | 2004-05-28T21:04:15 (when parsing) 2004-05-28 21:04:15 (when formatting) |
any other |
verbatim character | hh:mm:ss --- yyyy.MM+dd | 09:04:15 --- 2004.05+28 |
TIMESTAMP('2004-05-28', 'yyyy-MM-dd')
TIMESTAMP('21:04:15', 'hh:mm:ss')
TIMESTAMP('2', 'M')Similarly, unspecified time elements are replaced with zero values, unless the timestamp is a date-only timestamp value; for example, the following statement creates a time-only timestamp representing the time 10:00:00.0.0:
TIMESTAMP('10', 'h')As another example, the following statement creates a full timestamp value representing the time 10:00:00.0.0 on February 1, year 0:
TIMESTAMP('2 10', 'M h')
© 2004 Microsoft Corporation. All rights reserved.