LogParser Query Expecting From Keyword Instead of Token 'To_Timestamp'

Ou Cop 1 Reputation point
2022-03-30T15:19:24.127+00:00

I am writing a query in LogParser Studio (and have also tried it in command line LogParser 2.2) in trying to find results that have a date between two specified dates in the query.
I get the error message (below) whenever I run it.

"Error parsing query: Syntax Error: <from-clause>:expecting FROM keyword instead of token 'TO_TIMESTAMP(date,time)' [SQL query syntax invalid or unsupported.]"

Here is the query (below). Note that I do replace '[LOGFILEPATH]' with the actual path when I try this in the command line LogParser. Also, I've tried removing the single quotes in the dates, with no positive results.
Thanks for your help.

SELECT LocalDateTime, USING TO_TIMESTAMP(date,time) AS LocalDateTime into OUTPUT.CSV FROM '[LOGFILEPATH]' where LocalDateTime BETWEEN TIMESTAMP ('2012-011-06 13:50:00', 'yyyy-MM-dd hh:mm:ss') And TIMESTAMP ('2012-011-06 14:00:00', 'yyyy-MM-dd hh:mm:ss') order by LocalDateTime DESC

Windows development Internet Information Services
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce Zhang-MSFT 3,771 Reputation points
    2022-03-31T03:12:33.917+00:00

    Hi @Ou Cop ,

    I made some modifications to your query to fit my log. My log file doesn't have LocalDateTime so I change it to s-ip. I also removed into OUTPUT.CSV because there's another issue. I'm not sure if you have same issue. But it can work after remove it.
    188604-1.png

    If you also have this issue, try to remove into OUTPUT.CSV .

    So the issue is caused by USING TO_TIMESTAMP(date,time). If you want to use TO_TIMESTAMP function, just use it and no need to add USING.

    Same error with you.
    188539-3.png

    But it worked well after I removed the USING.
    188613-2.png


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,
    Bruce Zhang

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.