Click to See Complete Forum and Search --> : how can i compute the time difference between 2 time
Chaze
02-21-2006, 05:02 AM
good day guys,
how can i compute the time difference between to time.
for ex:
textfieldfrom = "7:30:00 AM"
textfieldto = "5:45:23 PM"
Thanks in Advance
cusimar9
02-21-2006, 09:17 AM
http://www.w3schools.com/vbscript/func_datediff.asp
Chaze
02-21-2006, 08:15 PM
Datediff is a Function that compute a date or time difference between two date, my problem is how can i compute a time difference between two time in the same dates. hope you can help me...
Thanks in Advance
Chaze
cusimar9
02-22-2006, 07:11 AM
Please take the time to read links posted...
DateDiff can take the following values:
* yyyy - Year
* q - Quarter
* m - Month
* y - Day of year
* d - Day
* w - Weekday
* ww - Week of year
* h - Hour
* n - Minute
* s - Second
document.write(DateDiff("h",Date1,Date2) & "<br />")
document.write(DateDiff("n",Date1,Date2) & "<br />")
document.write(DateDiff("s",Date1,Date2))
russell_g_1
02-22-2006, 01:12 PM
you probably can't do it like that because it will give you all the seconds and all the minutes in there, not just the ones left over after removing the hours and then minutes if you see what i mean.
i would try getting the total seconds and then adding it to 00:00:00.
like this
function getTimeDiff(date1,date2)
dim mydate,s
s = datediff("s",date1,date2)
mydate = dateadd("s",s,"00:00:00")
getTimeDiff = mydate
end function
if that's the format you want it in
Chaze
02-26-2006, 09:33 PM
I got it, Thank you guys
:)