h1

Windows Command Batch Scripting - Create a date string of format YYYYMMDD

December 28th, 2006

Below is the code to do this. I was frustrated at not being able to find a quick answer on this so hopefully this will help someone.

set today=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%

REF: http://www.ss64.com/ntsyntax/varsubstring.html

2 comments to “Windows Command Batch Scripting - Create a date string of format YYYYMMDD”

  1. Thanks a lot lot lot dude. Great work. :)


  2. And to get a time string in HHMMSS format: %time:~0,2%%time:~3,2%%time:~6,2%


Leave a Comment