Hi,
If i have 2 values in a database, how would i work out what the time is between the two times??
Example:
Value 1: 12:01:00 PM
Value 2: 12:02:24 PM
Then i want it to return 00:01:24
Any idea??
Thanks,
Ross
Printable View
Hi,
If i have 2 values in a database, how would i work out what the time is between the two times??
Example:
Value 1: 12:01:00 PM
Value 2: 12:02:24 PM
Then i want it to return 00:01:24
Any idea??
Thanks,
Ross
one way
VB Code:
x = DateDiff("s", value1, Value2) x = x \ 60 & ":" & x Mod 60
Moved to Database forum
Which database system are you using?
Do you want this done in an SQL statement, or in your program, or...?
Another possible method (may not work, depending on the kind of values you will have) is simply: Value2 - Value1
I tried this method and it came out like this:Quote:
Originally Posted by westconn1
Value 1 = 1:34:38 PM
Value 2 = 1:37:43 PM
x = 3:5
3:5 isn't really a time :p any ideas??
or the date diff posted above...Code:format(cdate(<value2>)-cdate(<value1>),"hh:nn:ss")
Value 1 and value 2 are text in my example (hence the cdate function).
Value 2 MUST be greater than value 1. Although you could wrap that in an abs function.
All dates are stored as long (I think) past a certain point in the past (until we go past 2029 then things may be interesting ;) )
So the above converts the text to dates (longs) and minuses one from the other. Whatever is left is formatted to a date.
format(cdate(<value2>)-cdate(<value1>),"hh:nn:ss")
is that meant to be mm??
No, as "m" is used for Month.