I am writing a VBScript to pass back the date/time value (especially before 2:00 AM to get last day value). Is there any fine tuning instead of pass the value to another batch and use the Batch1 to call vbscript and then the batch2 (created in vbscript)? Thanks a lot
dim dateMonth, dateDay, dateYear, dateYY, dateMMM, MM, pDateDay
'Check Time
if hour(now) < 2 then 'Before 2AM, count as last working day
dateMonth = Month(dateadd("d",-1,now))
dateDay = Day(dateadd("d",-1,now))
dateYear = Year(dateadd("d",-1,now))
dateYY = right(year(dateadd("d",-1,now)),2)
TimeHH = Hour(now)
TimeMM = Minute(now)
else
dateMonth = Month(now)
dateDay = Day(now)
dateYear = Year(now)
dateYY = right(year(now),2)
TimeHH = Hour(now)
TimeMM = Minute(now)
end if
MM = Array("","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
dateMMM = mm(dateMonth)
if dateMonth < 10 then
dateMonth = "0" & dateMonth
end if
If dateDay < 10 then
dateDay = "0" & dateDay
End if
If TimeHH < 10 then
TimeHH = "0" & TimeHH
End if
If TimeMM < 10 then
TimeMM = "0" & TimeMM
End if
Set objFSO=CreateObject("Scripting.FileSystemObject")
' Create Log file
Dim oFSO, oTxtFile, curDir
Set oFSO = CreateObject("Scripting.FileSystemObject")
curDir = oFSO.GetAbsolutePathName(".")
strFile = "\datetime.bat"
If oFSO.FileExists(curDir & strFile) then
oFSO.DeleteFile curDir & strFile
end if
strValue = "SET Date_MMDD=" & dateMonth & dateDay
strValue = strValue & vbcrlf & "SET Date_MM=" & dateMonth
strValue = strValue & vbcrlf & "SET Date_MMM=" & dateMMM
strValue = strValue & vbcrlf & "SET Date_DD=" & dateDay
strValue = strValue & vbcrlf & "SET Date_HHMM=" & TimeHH & TimeMM
strValue = strValue & vbcrlf & "SET Time_HH=" & TimeHH
strValue = strValue & vbcrlf & "SET Time_MM=" & TimeMM
Set oTxtFile = oFSO.CreateTextFile(curDir & strFile)
oTxtFile.writeline(strValue)
wscript.echo strValue
set oTxtFile = nothing
set oFSO = nothing