Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

time compare

Status
Not open for further replies.

krymzon

Programmer
Joined
Feb 22, 2005
Messages
38
Location
CA
just curious is there is an easy function embedded into asp that works in a similar manner to datediff(), but instead of working with dates it would work with times like 9;45 pm to 9;50 pm, etc. right now i shudder at the fact that i might have to make a function that would parse the text...lol. not that it would be hard, but eleminating extra work is always nice.

--there are 10 types of people in this world. those who know binary, and those who don't.--
 
DateDiff Does exactly what you want, with the interval argument set to "n" for minutes (or similarly, "h" for hour or "s" for seconds). Like this:
Code:
<%
Time1 = "8:30 pm"
Time2 = "9:45 pm"

Diff = DateDiff("n", Time1, Time2)

Response.Write(Diff
%>
which would result in "75".

If you wanted the results in hours and minutes, you'd just change the write to calculate each, like this:
Code:
Response.Write(Int(Diff / 60) & " hours and " & Diff Mod 60 & " minutes")
which would result in "1 hour and 15 minutes".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top