![]() |
![]() |
#1 |
I ♥ BOINC!
Oct 2002
Glendale, AZ. (USA)
45916 Posts |
![]()
If you don't enter an argument, it will take the current system date of your computer and change it from 'Sat 12/06/2008' and change it to 2008-12-06.
Assuming date /t gives you Sat 12/06/2008 ![]() cscript /nologo datediff.vbs 1 would show you 2008-12-05 cscript /nologo datediff.vbs 2 would show you 2008-12-04 cscript /nologo datediff.vbs 31 would show you 2008-11-05 Code:
' returns the date for how many days back you need to find the date for in YYYY-MM-DD format. Option Explicit Dim strNum, arrDate, strYear, strMonth, strDay, strDate Dim objArgs Set objArgs = WScript.Arguments if WScript.Arguments.Count < 1 then strNum = "0" Else strNum = Wscript.Arguments(0) End If arrDate = Split(DateAdd( "d" , -strNum , Date ), "/", -1, 1 ) strYear = arrDate(2) strMonth = arrDate(0) strDay = arrDate(1) if strMonth < 10 then strMonth = "0"&strMonth if strDay < 10 then strDay = "0"&strDay strDate = strYear & "-" & strMonth & "-" & strDay wscript.echo strDate for /f "tokens=*" %%a in ('cscript /nologo datediff.vbs 0') do set MyNewDate=%%a echo %MyNewDate% 2008-12-06 Last fiddled with by IronBits on 2008-12-06 at 09:23 |
![]() |
![]() |
![]() |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
vbscript help | IronBits | Programming | 18 | 2008-11-27 03:02 |