Followers 0

# tricky question, help plz

## 3 posts in this topic

does anyone know of an easy way to compair two different time stamps. I'll go into a little more details, when playing poker online, all hand historys are recorded into a program called poker tracker (as an mdb). The databases information is updated every minute, their is a column in a particular table which gives the time stamp of when a table is closed (session_end) eg 20060716051500 (year, month, day, hour, minute, second). In my script i need to know if a session is over 5 minutes old. I understand you can use a few built in macros to get the date/time, but is their any easy to say, if session_end time is 5 minutes or older then current time?

i tried to work it out but just got confused :\

thanks for any help.

##### Share on other sites

Instead of watching for the Universal Time Coordinate format modification. You can set WMI to watch the mdb file (hopefully is local). AutoIt Beta is needed for this. The output shown here will ConsoleWrite to the console of your editor if the modification event is older then 5 minutes.

; File to watch for modification
$file = 'Path\to\file.mdb' ; Setup WMI$sComputer = @ComputerName
$oWMIService = ObjGet("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" &$sComputer & "\root\cimv2")
$colMonitoredEvents =$oWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceModificationEvent WITHIN 10 WHERE " _
& "TargetInstance ISA 'CIM_DataFile' AND " _
& "TargetInstance.Name='" & StringReplace($file, '\', '\\') & "'") While 1 ; Reset timer to zero$time = TimerInit()
; Monitor file for event
$oLatestEvent =$colMonitoredEvents.NextEvent
; Output if event older then 5 minutes
If TimerDiff($time) > (5*60000) Then ConsoleWrite('Time: ' & @HOUR & ':' & @MIN & ':' & @SEC & @LF) ConsoleWrite("File: " &$oLatestEvent.TargetInstance.Name & @LF)
ConsoleWrite("New size: " & $oLatestEvent.TargetInstance.FileSize & @LF) ConsoleWrite("Old size: " &$oLatestEvent.PreviousInstance.FileSize & @LF)
EndIf
WEnd

##### Share on other sites

Instead of watching for the Universal Time Coordinate format modification. You can set WMI to watch the mdb file (hopefully is local). AutoIt Beta is needed for this. The output shown here will ConsoleWrite to the console of your editor if the modification event is older then 5 minutes.

; File to watch for modification
$file = 'Path\to\file.mdb' ; Setup WMI$sComputer = @ComputerName
$oWMIService = ObjGet("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" &$sComputer & "\root\cimv2")
$colMonitoredEvents =$oWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceModificationEvent WITHIN 10 WHERE " _
& "TargetInstance ISA 'CIM_DataFile' AND " _
& "TargetInstance.Name='" & StringReplace($file, '\', '\\') & "'") While 1 ; Reset timer to zero$time = TimerInit()
; Monitor file for event
$oLatestEvent =$colMonitoredEvents.NextEvent
; Output if event older then 5 minutes
If TimerDiff($time) > (5*60000) Then ConsoleWrite('Time: ' & @HOUR & ':' & @MIN & ':' & @SEC & @LF) ConsoleWrite("File: " &$oLatestEvent.TargetInstance.Name & @LF)
ConsoleWrite("New size: " & $oLatestEvent.TargetInstance.FileSize & @LF) ConsoleWrite("Old size: " &$oLatestEvent.PreviousInstance.FileSize & @LF)
EndIf
WEnd
MHZ ... thanks for your help ... you guidance for this post has helped me answer my query over here