correct format for datetime appended to filename

Posted by jhayes on Server Fault See other posts from Server Fault or by jhayes
Published on 2009-06-25T22:36:38Z Indexed on 2011/01/17 8:54 UTC
Read the original article Hit count: 239

Filed under:
|
|

I'm trying to setup a batch file to execute a set of stored procs and dump the output to a timestamped text file. I'm having problems finding the correct format for the timestamp.

Here is what I'm using

osql.exe -S <server> -E -Q "EXEC <stored procedure> " -o "c:\filename_%date:~-0,10%_%time:~-0,10%.txt"

The error I get is:

Cannot open output file - x:\filename_Thu 06/25/_16:26:43.1.txt No such file or directory

I can't find the documentation and I've played around with it but can't find the correct format.

© Server Fault or respective owner

Related posts about Windows

Related posts about time