日期格式改为字符串形式

--today.vbs--

today=Year(Date()) & Right("0" & Month(Date()),2) & Right("0" & Day(Date()),2)
wscript.echo today

 

--yesterday.vbs--

yesterday=DateAdd("d",-1,date)
yesterday_=Year(yesterday) & Right("0" & Month(yesterday),2) & Right("0" & Day(yesterday),2)
wscript.echo yesterday_

 

D:\>cscript /nologo yesterday.vbs
20101020

 

--test.bat--

 

@echo off
for /f %%i in ('cscript /nologo today.vbs') do set TODAY=%%i
rem there blank space at "today" string,i don't konw why.
set JINTIAN=%TODAY: =%
echo 今天日期是:%JINTIAN%

for /f %%i in ('cscript /nologo yesterday.vbs') do set YESTERDAY=%%i
set ZUOTIAN=%YESTERDAY: =%
echo 昨天日期是:%ZUOTIAN%

 

D:\>TEST.BAT
今天日期是:20101021
昨天日期是:20101020

 

posted @ 2010-10-21 15:01  abenz  阅读(506)  评论(0编辑  收藏  举报