http://www.sqlservercentral.com/blogs/sqldbauk/2011/07/20/dos-batch-file-date-and-time/

Printed 2014/09/21 04:54PM

DOS Batch File Date and Time

By Gethyn Ellis, 2011/07/20

Written by David POstlethwaite

A non SQL blog for a change
 
Ever needed to create a batch file that wrote a time stamped log file that ensures the day and month number always have two digits?
 
Try this:
 
SET Now=%Time: =0%
Set YYYYMMDD=%DATE:~6,4%_%DATE:~3,2%_%DATE:~0,2%_%now:~0,2%%now:~3,2%
 
echo running Batch File.... >> %YYYYMMDD%.txt

I hope you found this helpful, please feel free to leave a comment.



Copyright © 2002-2014 Simple Talk Publishing. All Rights Reserved. Privacy Policy. Terms of Use. Report Abuse.