Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Getting elapsed time in minutes

Reply
 
Old 01-26-2009   #1 (permalink)
wellsnet


 
 

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 SpecsSystem Spec
Old 01-26-2009   #2 (permalink)
Richard Mueller [MVP]


 
 

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.
I don't believe there any issues with the DateDiff function. The best
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 SpecsSystem Spec
Reply

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


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46