
Comparing Times
Is there a function that compares two times, like the dateDiff() function, but can return hours and/or minutes.

RE: Comparing Times
no, but it's a relatively trivial task to write one of your own.

something like this
http://www.aspmessageboard.com/forum/asp.asp?M=445255&F=20&P=1

RE: Comparing Times
'compare minutes because you can easyly transform to hours+minutes<BR> <BR>MyHoursAndMinutes = datediff("n",mydate1, mydate2)/60<BR><BR>'**substract the integer part to get the decimal part<BR>myMinutes = MyHoursAndMinutes  CInt(MyHoursAndMinutes)<BR><BR>'get the hours<BR>MyHours = CInt(MyHoursAndMinutes)<BR><BR>'get the minutes<BR>myMinutes = myMinutes*60<BR><BR>'display the result, you should put it in a function<BR>response.write "hours=" & myHours & " ; Minutes=" & minutes<BR><BR>'I didnt try it , but it is an idea. For more details replay.<BR><BR>pp:<BR><BR>and for the other guy, why he bothers to write something if he is not helping? "No question is stupid or advanced blah blah blha" is not something written in the header of this messageboard?

I wrote my own function
I wrote my own timeDiff function instead, so I can return how many hours or minutes between the two times, if you're intrested in a function like this feel free to take mine:<BR><BR>FUNCTION timeDiff(what,date1,date2)<BR>IF what="h" THEN<BR><BR>h = Split(date1,":")<BR>date1=cInt(h(0))<BR><BR>h= Split(date2, ":")<BR>date2=cInt(h(0))<BR><BR>IF date1 > date2 THEN<BR>remainingHours=date1date2<BR>ELSEIF date1 < date2 THEN<BR>remainingHours=date2date1<BR>ELSE<BR>remainingHours=0<BR>END IF<BR>timeDiff=remainingHours<BR><BR>ELSEIF what="m" THEN<BR><BR>h = Split(date1,":")<BR>hour1=cInt(h(0))<BR>date1=cInt (h(1))<BR><BR>h= Split(date2, ":")<BR>hour2=cInt(h(0))<BR>date2=cInt(h(1))<BR><B R>IF hour1 > hour2 THEN<BR>theHour=(hour1hour2)*60<BR>ELSEIF hour1 < hour2 THEN<BR>theHour=(hour2hour1)*60<BR>ELSE<BR>theHour=0<BR>END IF<BR><BR>IF date1 > date2 THEN<BR>remainingMins=(date1date2)+theHour<BR>ELSEIF date1 < date2 THEN<BR>remainingMins=(date2date1)+theHour<BR>ELSE<BR>remainingMins=0<BR>END IF<BR>timeDiff=remainingMins<BR><BR>ELSE<BR>timeDi ff="Invalid Character, use ""m"" or ""h"""<BR><BR>END IF<BR><BR>END FUNCTION

RE: I wrote my own function
Naa, you do not consider the date here, only the hour/minutes. Would you buy that?<BR><BR>so timeDiff ( 'h' '08/31/02 12:00', '07/31/02 01:00' ) would be 1 ???<BR><BR>use the dateDiff function and compute whatever you want from there

RE: I wrote my own function
I know that's what I want to do, I'm only dealing with the time in 00:00:00 format (time()) because I'm tracking something from 24 hours ago that will only have a time attached to it, I suppose I didn't state how specific I wanted it to be, thanks for your help.
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules

