Wednesday, January 30, 2008

Get the current date as a string from a batch file

Ever needed to include the current date in something like a filename from a batch file? Check out this MS KB article on how to do it.

I've changed the format slightly to include a dash between each part. This is what I used:

SET current.date=%date:~-4,4%-%date:~-7,2%-%date:~0,2%

No comments: