记录 Parser2.2 TO_DATE & TO_TIMESTAMP 转换
Log Parser2.2 TO_DATE & TO_TIMESTAMP conversion
刚开始使用 log parser 2.2,所以如果这太傻了,请原谅,但我一直坚持将字符串转换为时间戳。
以下查询从日志文件中以字符串格式输出日期
$>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
我需要在 csv 中插入上面的字符串,或者 table 但它应该是日期格式。
如果我尝试以下操作,输出只是 -
:
$>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
我试图解析的日志文件条目类似于:
3:12:40 (lmgrd) TIMESTAMP 2/6/2015
知道出了什么问题吗?我期望输出与日期格式的字符串相同。
我也试过 M/d/YYYY
但得到相同的输出。
试试小写 'y':
M/d/yyyy
这里是时间戳元素的描述:
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
刚开始使用 log parser 2.2,所以如果这太傻了,请原谅,但我一直坚持将字符串转换为时间戳。
以下查询从日志文件中以字符串格式输出日期
$>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
我需要在 csv 中插入上面的字符串,或者 table 但它应该是日期格式。
如果我尝试以下操作,输出只是 -
:
$>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
我试图解析的日志文件条目类似于:
3:12:40 (lmgrd) TIMESTAMP 2/6/2015
知道出了什么问题吗?我期望输出与日期格式的字符串相同。
我也试过 M/d/YYYY
但得到相同的输出。
试试小写 'y':
M/d/yyyy
这里是时间戳元素的描述:
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