Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.
Set objFS=CreateObject("Scripting.FileSystemObject")Set objArgs = WScript.ArgumentsstrFile = objArgs(0)Set objFile = objFS.OpenTextFile(strFile)CurrentDateTime =NowDo Until objFile.AtEndOfStream strLine = objFile.ReadLine s = Split(strLine," ") t="" For i = 3 To UBound(s) t = t &" "&s(i) Next t=Trim(t) datetime = Split(t," ") mth= datetime(0) dy = datetime(1) thetime = Split(datetime(2),":") hr = thetime(0) min = thetime(1) sec = thetime(2) theyr = datetime(3) strDateTimeInFile = CDate( dy & " " & mth & " " & theyr) &" "&CDate( hr & ":" & min & ":" & sec ) If DateDiff( "d", CurrentDatetime ,strDateTimeInFile ) > -1 Then WScript.Echo "CurrentTime is earlier than strDateTimeInFile" WScript.Echo strLine End If Loop
c:\test> cscript /nologo test.vbs file
strDateTimeInFile = CDate( dy & " " & mth & " " & theyr) &" "&CDate( hr & ":" & min & ":" & sec )
DateTimeInFile= DateSerial(theyr,mth,dy)+TimeSerial(hr,min,sec)
Can it be done using batch dos commands?beacause i am not more concern about date comparison, comparison parameter could be no's also.
nicejust one thing Why use CDate and String concat? You could use DateSerial and TimeSerial; also, this will allow for the return type to be a Date, rather then a string. (although I imagine type coercion is making everything work as it is; you can never really be sure in different locales)Code: [Select]DateTimeInFile= DateSerial(theyr,mth,dy)+TimeSerial(hr,min,sec)
beacause i am not more concern about date comparison, comparison parameter could be no's also.
heh, i had always wanted to try using these 2 functions, but never really got to it. CDate is what i am familiar with so i just wrote the script without much thinking. But good call though.
He's playing a game called IRL. Great graphics, *censored* gameplay.
@echo off>output.txtsetlocal enabledelayedexpansion:: set time=%1set time=%time::=%set time=%time:~0,6%for /f "delims=*" %%1 in (abc.txt) do ( set line=%%1 for /f "tokens=1-6" %%2 in ("!line!") do ( set filetime=%%7 set filetime=!filetime::=! if !filetime! leq !time! echo %%1>>output.txt) )type output.txt
rem set Ct=%time%rem echo Ct = %Ct%rem set Ctt=%Ct:~0,2%set Ctt=08echo Ctt = %Ctt%@echo offsetlocal enabledelayedexpansionfor /f "tokens=1-7" %%i in (abc5.txt) do (set LD=%%necho LD=!LD!set LDD=!LD:~0,2!echo LDD=!LDD!echo LDD less or equal Cttif !LDD! LEQ !Ctt! (echo %%i %%j %%k %%l %%m %%n %%o) else (echo.echo No result foundecho. )