tags:

views:

31

answers:

2

I have DateFirstStarted and DateEnded fields in the database.

Date values are recorded as

DateFirstStarted
04/13/2010 07:00:00.000 PM
DateEnded
04/13/2010 09:00:00.000 PM

How do I print minute difference between two dates. I tried the following code but it returned something like 999343

Clock   =   DateDiff("m", objLiveCommentary("DateFirstStarted"), objLiveCommentary("DateEnded"))
A: 

Try "n" instead.

Clock = DateDiff("n", objLiveCommentary("DateFirstStarted"), objLiveCommentary("DateEnded"))

Edit: Also, make sure what you're passing in is really a correct date value. Is objLiveCommentary returning a string? If so, what?

tloflin
Tried that too, I got 58005900.
zurna
A: 

I just ran your code with Cscript to check and your dates don't parse properly with VBScript. Maybe you have something else coming out of the DB. The .000 on the end of your times is causing CDate to fail for me. Using the following I get the correct result. 120min

dim d1
dim d2
d1= "April 13 2010 07:00:00PM"
d2= "April 13 2010 09:00:00PM"

Clock = DateDiff("n", d1, d2)
Wscript.echo Clock
Paul Farry