2

I have cpu monitors constantly workning on my computer. I would like log parser to parse results only from the last hour. does anyone know how to do that?

SELECT TO_STRING(QUANTIZE(TO_TIMESTAMP(Field1, 'mm/dd/yyyy HH:mm:ss.ll'),10 ), 'hh:mm:ss') AS Time, AVG(TO_REAL(Field2)) AS Cpu
INTO .\output\cpu.csv
FROM .\logs\*.csv   
WHERE Time >= SUB( TO_LOCALTIME(SYSTEM_TIMESTAMP()), TIMESTAMP('0000-01-02', 'yyyy-MM-dd') )

the last line results with an error. does anyone know how can i do that? thanks!

1 Answer 1

7

Your WHERE clause is wrong; instead of pulling 1 hour, you're pulling 1 day.

The following worked on IIS logs:

SELECT TO_STRING(QUANTIZE(TO_TIMESTAMP(date, time),10 ), 'hh:mm:ss') AS Time
INTO asdf.csv
FROM W3SVC5\*ex*.log
WHERE TO_LOCALTIME(TO_TIMESTAMP(date, time)) >= SUB( TO_LOCALTIME(SYSTEM_TIMESTAMP()), TIMESTAMP('0000-01-01 01:00', 'yyyy-MM-dd HH:mm') )

For your particular case you should be safe just using this bit of the WHERE clause:

SUB( TO_LOCALTIME(SYSTEM_TIMESTAMP()), TIMESTAMP('0000-01-01 01:00', 'yyyy-MM-dd HH:mm') )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.