There's no need to use string concatenation operators to accomplish this.
"Select * from u_ex$(get-date -format 'yyMMdd')x.log"
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am trying to write a query in Log Parser 2.2 to dynamically fill in the LogFileDate field with todays date. I have to do this since W3C format doesn't allow for -iCheckPoint
From my research, I can use powershell and the get-date function:
E:"Log Parser 2.2"\LogParser.exe ""Select * from u_ex"+(get-date -format "yyMMdd")+"_x.log
""
If I run this in powershell, it says Syntax Error: extra token after query '+'
If I just run ""Select * from u_ex"+(get-date -format "yyMMdd")+"_x.log
"", it comes back with "Select * from u__ex230328_x.log", which is correct. Can I not run it inline?
Would it be easier to run it in command line with TO_STRING(SYSTEM__DATE(),'yyMMdd'
I'd like to schedule this eventually so not sure if PowerShell or CmdLine (via bat file) would be easier
There's no need to use string concatenation operators to accomplish this.
"Select * from u_ex$(get-date -format 'yyMMdd')x.log"
I found this cmd/bat example in my notes.
**** Basic display ****
logparser "SELECT TO_LOCALTIME(TO_TIMESTAMP(date,time)) as [Local Time], cs-host, c-ip, cs-username,sc-status, cs-uri-stem, SUBSTR(cs-uri-query,0,50) FROM 'E:\inetpub\LogFiles\ex%date:~12,2%%date:~4,2%%date:~7,2%.*' where c-ip = '162.109.77.72' " -rtp:-1 -recurse
For powershell you can set a variable or enclose the parameters in $() so that PS evaluates everything. (I think that will work. I don't have logparser installed on my laptop.)
$parms = "Select * from u_ex"+(get-date -format "yyMMdd")+"_x.log"
logparser.exe $parms
logparser.exe $("Select * from u_ex"+(get-date -format "yyMMdd")+"_x.log")