
November 9th, 2008, 03:14 AM
|
|
Registered User
|
|
Join Date: Sep 2007
Posts: 5
Time spent in forums: 2 h 20 m 47 sec
Reputation Power: 0
|
|
|
Date format windows shell script
Hello, I wrote a small batch file that will print today and yesterday date to be used in anther application. problem is with yesterday date, if the date is between 1 to 9 it will print it with out "0", i mean like "2008119" instead of printing it as "20081109".
this is the script:
Code:
@echo off
REM Set Date format
FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B
FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B
FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %CDATE%') DO SET dd=%%B
FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('echo %CDATE%') DO SET yyyy=%%B
SET date=%yyyy%%mm%%dd%
echo today is %date%
REM define yesterday date
set /A dd=%dd%-1
set Pdate=%yyyy%%mm%%dd%
echo yesterday was %Pdate%
exit
any idea ?
|