James Cochrane
asked on
Need to format the current date to YYYYMMDD
I have a batch file that is going to be called automatically. It looks for a file that will have the current date as part of the file name. I need a DOS script that can take the current date, transform it to the format YYYYMMDD and then append that to the base of the file name in order to process the file. As an example, the base of the file name is ABC- so the script needs to get the current date and append it as follows:
ABC-20110923.csv
I have been trouble finding information on how to do that.
Thanks for your help.
ABC-20110923.csv
I have been trouble finding information on how to do that.
Thanks for your help.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The "easy" way as shown involving %date% is difficult when using different machines, OS's or logins as the format changes. VBScript will work the same every time.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Which proves my point :-)
Steve's article has some great approaches to this.
I'll just add that I often use a tiny free utility called DOFF for this which can be found at:
http://www.jfitz.com/dos/index.html#DOFF
If that's any interest to you and you have questions let me know.
~bp
I'll just add that I often use a tiny free utility called DOFF for this which can be found at:
http://www.jfitz.com/dos/index.html#DOFF
If that's any interest to you and you have questions let me know.
~bp