|
Question : getDate and setDate in dos
|
|
hi ppl
i wanted to extract the current date and put it into "today" and later on put "tempDate" in to the current date of the system. so far i only know how to extract current date from the system with set tempDate = %date% but when i try set $date = tempdate it doesn't understand that $date is the environment variable
i even tried date tempdate date %tempdate% but they also don't work
pls help thanks
|
|
Answer : getDate and setDate in dos
|
|
It is not clear what you are trying to accomplish. If you are simply trying to record the current value of %date% and then put it back:
set tempdate=%date% set date=%tempdate%
This will not work if you are trying to change the actual system date, the changed variable is only valid in the current shell prompt.
If you are trying to change the actual system date back to the saved value try:
To record current date.... for /f "tokens=2" %%i in ('date /t') do set tempdate=%%i
(Change %%i to %i if this will not be in a batch file)
To restore the date.... echo %tempdate% | date
|
|
|