Discussion Locked

shell script date

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
How can I use the current (system)date as a variable in a NT shell script?

1 reply

by timthetoolman

Hi,

There is no direct access to the date from an NT shell script, but you can access it by doing something like...

date /t > temp.txt
for /F "tokens=2*" %i in (temp.txt) do echo %i

will set the environment variable %i to the date.
Here is an example...

E:\Documents and Settings\Tim Medhurst>date /t > temp.txt

E:\Documents and Settings\Tim Medhurst>for /F "tokens=2*" %i in (temp.txt) do echo %i

E:\Documents and Settings\Tim Medhurst>echo 01/04/2002
01/04/2002

E:\Documents and Settings\Tim Medhurst>

Cheers,
Tim.

This discussion is closed to new replies.