Get the Date Information for your batch file. If you like me still need to create DOS batch file to automate some jobs in the server give this a try.
%DATE% is the environment variable which you can use to return the date in the batch file, you can format it by extract the YEAR, MONTH and DAY using this command %DATE:~[BeginPos],[NoOfChar]% (it’s like substring command). Example;
C:\>echo %Date:~6,4%-%Date:~3,2%
2006-08
Please take note that the return date format are according to the system Regional Settings.
For those using Windows NT more information are available in link below
http://www.robvanderwoude.com/index.html
According to the web site above the %DATE% variable suppose to work in NT SP6a but I dunno why it did not work in mine. So I have to use the format below;
@ECHO OFF
FOR /F “TOKENS=*” %%A IN (’TIME/T’) DO SET TIME=%%A
ECHO It’s %TIME% now
No comments:
Post a Comment