Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch File with System Date

Status
Not open for further replies.

iuianj07

Programmer
Sep 25, 2009
293
US
Hello guys,

Not sure if this is the right section to ask, if not please lead me to the right direction.

I just created a batch file, that would copy a file and the destination file would have an automated date in its file name, I actually wrote this friday and when I test run it, it ran correctly having the friday's date (73010) but when I ran the same batch file again today, its not renaming it correctly, it is now renaming %dte% as 08MAR10... Please help me out figuring out how to fix this.


set day=%date:~-10,2%
set mnth=%date:~-7,2%
set yr=%date:~-2,2%
if %mnth%==01 set mnth=JAN
if %mnth%==02 set mnth=FEB
if %mnth%==03 set mnth=MAR
if %mnth%==04 set mnth=APR
if %mnth%==05 set mnth=MAY
if %mnth%==06 set mnth=JUN
if %mnth%==07 set mnth=JUL
if %mnth%==08 set mnth=AUG
if %mnth%==09 set mnth=SEP
if %mnth%==10 set mnth=OCT
if %mnth%==11 set mnth=NOV
if %mnth%==12 set mnth=DEC
set dte=%day%%mnth%%yr%

echo F | xcopy "\\n-sitnc-fp0\Data\LIVE WORK\2010\DDNC100001_WFB Financial Statement Analysis\test.xls" "\\n-sitnc-fp0\Data\LIVE WORK\2010\DDNC100001_WFB Financial Statement Analysis\TEST\test_%dte%.xls" /Y/Q

Thanks
 
Probably a locale issue (mm/dd/yyyy vs dd/mm/yyyy)
I'd replace this:
set day=%date:~-10,2%
set mnth=%date:~-7,2%
with this
set day=%date:~-7,2%
set mnth=%date:~-10,2%

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hello,

it's working now, it now returns the value 03AUG10.

It's odd though that last week it was returning to the right date, but now I had to change the code.

Is this going to be an issue going forward that I need to constantly change the code?

Thank you!
 
I think it's depend on your regional settings.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top