![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Getting elapsed time in minutes Hi - have a snippet that finds elapsed minutes between 2 date properties of object instances in an event log where event 20 occurs 1st and event 4 occurs 2nd: If objItems.EventCode = 4 AND objItems.LogFile = "Application\" AND objItems.SleepTracker = "Not Processed\" Then endsleep = trim(objItems.TimeHolder) For Each objItems2 in colItems If objItems2.EventCode = 20 AND objItems2.SleepTracker = "Not Processed\" Then startsleep = trim(objItems2.TimeHolder) SkipCount = 1 End If Next TimeDiff = cstr(DateDiff("N\",startsleep,endsleep)) objItems.SleepCount = TimeDiff objItems.Put_ End If TimeDiff should always return a positive number of minutes since the 1st event is always a 20 event that precedes a 4 event. TimeHolder is a time holder value for events. However, I am getting negative numbers for quite a few of them. Assuming the 20 event always precedes the 4 event, is there a reason I would get negative elapsed minutes? Is there an issue wrapping around dates with DateDiff in minutes? Any other known stumbling blocks with DateDiff? TIA. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Getting elapsed time in minutes "wellsnet" <wellsnet@xxxxxx> wrote in message news:8C3D49EE-6884-4E2B-BD98-92F661E5B799@xxxxxx Quote: > Hi - have a snippet that finds elapsed minutes between 2 date properties > of > object instances in an event log where event 20 occurs 1st and event 4 > occurs > 2nd: > > If objItems.EventCode = 4 AND objItems.LogFile = "Application\" AND > objItems.SleepTracker = "Not Processed\" Then > endsleep = trim(objItems.TimeHolder) > For Each objItems2 in colItems > If objItems2.EventCode = 20 AND objItems2.SleepTracker = "Not > Processed\" Then > startsleep = trim(objItems2.TimeHolder) > SkipCount = 1 > End If > Next > TimeDiff = cstr(DateDiff("N\",startsleep,endsleep)) > objItems.SleepCount = TimeDiff > objItems.Put_ > End If > > TimeDiff should always return a positive number of minutes since the 1st > event is always a 20 event that precedes a 4 event. TimeHolder is a time > holder value for events. However, I am getting negative numbers for quite > a > few of them. > > Assuming the 20 event always precedes the 4 event, is there a reason I > would > get negative elapsed minutes? Is there an issue wrapping around dates > with > DateDiff in minutes? Any other known stumbling blocks with DateDiff? > > TIA. explanation is that endsleep is less than (before) startsleep. Also, I've never seen "N\". Shouldn't it be "n"? -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Zombie PCs: ‘Time to infection is less than five minutes’ | Vista News | |||
| Time email received is 23 minutes off | Vista mail | |||
| How to change WMP setting from time elapsed to time to go | Vista music pictures video | |||
| Vista Offline Files Consuming 100% CPU for 2 minutes every few minutes | Vista General | |||
| 5+ minutes boot time | Vista General | |||