
About my earlier question..
I asked about Datediff earlier, and I think I received a good answer. I guess my only other question is this..<BR>If I do a datediff between two values, and i use the "m" interval...how can i display the value returned in hours:minutes:seconds format?

RE: About my earlier question..
How about this for a hint:<BR><BR>***** timeDemo.asp *********<BR><HTML><BODY><BR>< BR><%<BR>dt = TimeSerial( 0, 0, 17366 )<BR>%><BR>Time is <% = dt %><BR><BR></BODY></HTML><BR>*****************************<BR><BR >If you just chop off the "AM", that will work up to 12 hours. 24 hours if you format it for 24hour time.<BR><BR>If you need more than that, you'll have to do the conversion by hand:<BR><BR><%<BR>hrs = numMinutes 60<BR>mins = numMinutes MOD 60<BR>Response.Write "Elapsed time: " & hrs & ":" & Right( "0" & mins, 2 ) & "<P>"<BR>%><BR><BR>No point in displaying seconds, given your question, since there will never be any.<BR><BR>

RE: About my earlier question..
Thank you Bill. What if the number of minutes is like 2400? How would I include days in this?

Are you going to ask about months?
If so, how many days per month? <grin><BR><BR>Learn about the and MOD operators: <BR><BR> does *integer* division: 7 3 is 2, not 2.3333333, for example.<BR><BR>MOD gets the *remainder* after integer division is used: 7 MOD 3 is 1. Remember 3rd or 4th grade arithmetic, where you get an answer like "2 rem 1"? Well and MOD give you those two numbers.<BR><BR>So:<BR><BR><%<BR>numMins = ....<BR><BR>days = numMins (24 * 60)<BR>mins = numMins MOD (24 * 60)<BR>hrs = mins 60<BR>mins = mins MOD 60<BR><BR>Response.Write "Elapsed: " & days & " days, " & hrs & " hours, " & mins & " minutes"<BR><BR>

RE: About my earlier question..
Hey Bill, before you waste your time on that question about days. I found out that I don't need days, but I do need seconds. So, my question is, how do I get hh:mm:ss out of a difference of 2400 minutes? Or, would it be easier to do 64000 seconds?

RE: Are you going to ask about months?
Man, I'm sorry. You're right..I need to learn more cuz I'm new at this. But, of course, they ask me to do the difficult things first. I appreciate all your help.

Always 00 seconds...
...if the difference is in minutes, then the number of seconds is *always* 0, so simply tack on ":00" and be done.<BR><BR>Note that if you do DateDiff("n"...) you will *not* get fractional minutes.<BR><BR>

RE: Always 00 seconds...
What if I do DateDiff("s"..)?

Then just extend the logic...
mins = differenceInSeconds 60<BR>secs = differenceInSeconds MOD 60<BR><BR>and work with minutes exactly as before.<BR><BR>
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

