tankman1989
Gawd
- Joined
- Aug 21, 2009
- Messages
- 588
I'm having problems getting the date to appear correctly in my batch files. I am creating a rar backup of a folder and I want the date to appear in the filename. I have tried using the %date% variable as well as more advanced versions of "date" such as:
MYDATE=%DATE:~0,2%%DATE:~3,2%%DATE:~8,4%
MYDATE=%date:~0,4%%date:~5,2%%date:~8,2%
MYDATE=%date:~0,2%-%date:~3,2%-%date:~6,4%
MYDATE=%DATE:~6,4%%DATE:~0,2%%DATE:~3,2%
MYDATE=%DATE:~6,4%%DATE:~3,2%%DATE:~0,2%
It doesn't matter what date (or %mydate% as the above 5 examples) I use, I get the backup_filename followed by a 3 letter version of the date, such as:
backup_file_Fri.rar or
backup_file_Sat.rar
Can anyone tell me what I'm doing incorrectly?
MYDATE=%DATE:~0,2%%DATE:~3,2%%DATE:~8,4%
MYDATE=%date:~0,4%%date:~5,2%%date:~8,2%
MYDATE=%date:~0,2%-%date:~3,2%-%date:~6,4%
MYDATE=%DATE:~6,4%%DATE:~0,2%%DATE:~3,2%
MYDATE=%DATE:~6,4%%DATE:~3,2%%DATE:~0,2%
It doesn't matter what date (or %mydate% as the above 5 examples) I use, I get the backup_filename followed by a 3 letter version of the date, such as:
backup_file_Fri.rar or
backup_file_Sat.rar
Can anyone tell me what I'm doing incorrectly?