time to calculate...

Rhoarke
09-29-2000, 03:45 PM
Greetings, all. Is there an easy way to calculate the number of seconds and/or minutes b/w two times of day? Now, before you jump to the reply button, lemme explain: I have written TOD (time of day) HH:MM:SS PM to a field in a database, and logged a 'begin' statement in an adjacent field. The next row has a time, and an 'end' entry. See:

Begin.....12/12/00.....3:37:18 PM
End.......12/12/00.....3:38:07 PM

Now, how do I read those two fields (I can make these be TIME/DATE type or STRING type) and calculate elapsed time? There will eventually be hundreds of these, blah, blah, blah. AddTime and TimeDiff methods are balking, b/c there is no DATE (the 12/12/00 part) in the field-only the HH:MM:SS PM. Is this going to be a huge mess? If absolutely necessary (Grrr...) I can combine my DATE field and TIME fields which would ease my use of TimeDiff...but I'd rather leave them separated. Does this make any sense? Plz help if you understand. :)
-r

fyntan
09-29-2000, 04:56 PM
Try the DateDiff() function

eg
current_date = Now
min = DateDiff("n", current_date, to_date)

for the dates based upon minutes difference then you can calc back up using an 'hours' and 'days' with Modulus

If (min > 59) Then
hour = min 60
min = (min Mod 60)
If (hour > 23) Then
day = hour 24
hour = (hour Mod 24)
Else
day = 0
End If

Rhoarke
10-04-2000, 03:00 PM
But you see, the calculated time I need is not between "Now" and a timedate entry. It is between two entries in a database, both of which are ONLY hh:mm:ss PM. I need some way to calculate elapsed time given only this info. Say 12:37:10 PM and 12:38:11 PM were entries. I need to know how to return either 61 seconds (in any format) or 1.16 minutes. As I said in my post: TimeDiff doesn't work in the basic sense, and my guess is that I'm going to have to manipulate what is put into said function before it will take the data. Any other ideas?
-R

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum