Just started using log parser 2.2, so please excuse me if this is too silly, but I am stuck at converting a string to timestamp.
The following Query gives me an output of the date in string format from a log file
$>logparser -i:textline -RTP:-1 "SELECT TOP 1 EXTRACT_SUFFIX(text,0,'TIMESTAMP') from 'C:\ptclmgrd.log' where text like '%TIMESTAMP%'"
EXTRACT_SUFFIX(Text, 0, 'TIMESTAMP')
------------------------------------
2/6/2015
Statistics:
-----------
Elements processed: 951
Elements output: 1
Execution time: 0.03 seconds
I need to insert the above string in csv, or table but it should be in date format.
If I try the following, the output is just -
:
$>logparser -i:textline -RTP:-1 "SELECT TOP 1 TO_TIMESTAMP(EXTRACT_SUFFIX(text,0,'TIMESTAMP'),'MM/dd/yyyy') from 'C:\ptclmgrd.log' where text like '%TIMESTAMP%'"
TO_TIMESTAMP(EXTRACT_SUFFIX(Text, 0, 'TIMESTAMP'), 'MM/dd/yyyy')
----------------------------------------------------------------
-
Statistics:
-----------
Elements processed: 951
Elements output: 1
Execution time: 0.01 seconds
The log file entry that I am trying to parse is something like:
3:12:40 (lmgrd) TIMESTAMP 2/6/2015
Any idea what's wrong? I am expecting the output as same string in date format.
I also tried M/d/YYYY
but getting same output.
Try with lower-case 'y':
M/d/yyyy
Here is a description of the timestamp elements:
y 1-digit year
yy 2-digit year
yyy 3-digit year
yyyy 4-digit year
M month as digit without leading zeros
MM month as digit with leading zeros
MMM month as 3-character abbreviation of month name
MMMM month as full month name
d day as digit without leading zeros
dd day as digit with leading zeros
ddd day as 3-character abbreviation of day name
dddd day as full day name
h,H hour without leading zeros
hh,HH hour with leading zeros
m minutes without leading zeros
mm minutes with leading zeros
s seconds without leading zeros
ss seconds with leading zeros