DOS date format YYYY-MM-DD


[ Follow Ups ] [ Post Followup ] [ The EasyDOS Forum ] [ FAQ ]

Posted by Paul on April 16, 2012 at 11:09:31:

I have written a small DOS .bat file copied below to archive local files to the network regularly ~ which is working well.

The problem is XDate is in the format DD-MM-YYYY and archives are sorting themselves by day not by date.

How do I change the format to YYYY-MM-DD?


@echo off
for /f "tokens=1-3 delims=/- " %%a in ('date /t') do set XDate=%%a-%%b-%%c
for /f "tokens=1-2 delims=: " %%a in ('time /t') do set XTime=%%a.%%b
echo %XDate% %XTime%

md "\\\Archive\%Xdate%_DatabaseArchive"
xcopy "c:\temp\databases\*.*" "\\\Archive\%Xdate%_DatabaseArchive" /s /y



Follow Ups:



Post a Followup (use TAB key to move between boxes - NOT ENTER or RETURN)

Name:
E-Mail:

Subject:

Type your comments in the box below and SUBMIT:


[ Follow Ups ] [ Post Followup ] [ The EasyDOS Forum ] [ FAQ ]