Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

date logic in logparser

401 views
Skip to first unread message

Gary Chan

unread,
Apr 4, 2003, 2:57:07 AM4/4/03
to
is there some sort of date logic variables such as now()
or to datediff() in logparser? I am trying to only grab
the last 24 hour records from IIS log.

Ritchie

unread,
Apr 4, 2003, 8:01:41 AM4/4/03
to
"Gary Chan" <gary...@yahoo.com> wrote in message news:007d01c2fa7f$ca1416e0$3001...@phx.gbl...

> is there some sort of date logic variables such as now()
> or to datediff() in logparser? I am trying to only grab
> the last 24 hour records from IIS log.

Ah LogParser... the utility from Hell. Makes JT.EXE seem like a
walk in the park :)

LogParser doesn't have built-in dateadd/datediff functions. However it
does have a SUB() function. Trouble is, it doesn't behave as expected
where dates/times are concerned. For instance SUB(now, now) equals 11-30
and not zero!

And because of this offset, SUB(today - yesterday) equals 12-01. Soooo,
to retrieve yesterdys logs, make your SQL statement something like: -

SELECT *
FROM *.log
WHERE TO_STRING(SUB(TO_LOCALTIME(SYSTEM_TIMESTAMP()),
date), 'yyyy-MM-dd') = '12-01'

Alternatively create the SQL statement on the fly, something like:-

@echo off&setlocal
set sql=yesterday.sql
type nul %sql%
>>%sql% echo/SELECT *
>>%sql% echo/FROM *.log
>>%sql% echo/WHERE date = '%yy%-%mm%-%dd%'

Where variables %yy%, %mm% and %dd% contain yesterdays date, search this
group or see http://www.commandline.co.uk/cmdfuncs/dandt/ to find out how.

--
Ritchie


Gary Chan

unread,
Apr 4, 2003, 3:00:57 PM4/4/03
to
JT.exe? is this a free tool too? How can I find more
info about this?

>.
>

Ritchie

unread,
Apr 4, 2003, 3:23:22 PM4/4/03
to
"Gary Chan" <gary...@yahoo.com> wrote in message news:049d01c2fae4$e82aed10$3301...@phx.gbl...

> JT.exe? is this a free tool too? How can I find more
> info about this?

It's nothing to do with log parsing, I only mentioned it as it has
a steep learning curve, but not when compared with LogParser
date arithmetic.

JT is part of the resource kit and a free download from MS. Its a
commandline interface for the "Task Scheduler" service. You could
always search this group for more info (hint hint): -

http://groups.google.com/groups?q=cmdprompt.admin+jt

--
Ritchie


Curtis Anderson

unread,
Apr 6, 2003, 8:07:20 PM4/6/03
to
Ritchie wrote:
> Ah LogParser... the utility from Hell. Makes JT.EXE seem like a
> walk in the park :)

LOL! If that doesn't descibe LogParser to a T then I don't know what does!


0 new messages