another great challenge for all you asp gurus

Results 1 to 3 of 3

Thread: another great challenge for all you asp gurus

  1. #1
    Join Date
    Dec 1969
    Posts
    144

    Default another great challenge for all you asp gurus

    ok....the code below puts out the result as hh:mm:ss<BR>I need it to read in mm only. i.e. 01:10:20 should read 70 minutes.<BR>here is the code:<BR>&#060;% @LANGUAGE="VBSCRIPT" &#037;&#062;<BR>&#060;%<BR>dim ok<BR>my_date=time()<BR><BR>timenow = my_date<BR>ok = Request.Form("time1")<BR>difference = DateDiff("s", ok, timenow)<BR><BR>function getTime(difference)<BR>Hours = 3600<BR>Minutes = 60<BR>myHours = difference Hours<BR>hSubtract = myHours * Hours<BR>myMinutes = (difference - hSubtract) Minutes<BR>mSubtract = myMinutes * Minutes<BR>mySeconds = difference - (hSubtract + mSubtract)<BR>if myHours &#060;= 9 then<BR>myHours = "0" & cStr(myHours)<BR>else<BR>myHours = cStr(myHours)<BR>end if<BR>if myMinutes &#060;= 9 then<BR>myMinutes = "0" & cStr(myMinutes)<BR>else<BR>myMinutes = cStr(myMinutes)<BR>end if<BR>if mySeconds &#060;= 9 then<BR>mySeconds = "0" & cStr(mySeconds)<BR>else<BR>mySeconds = cStr(mySeconds)<BR>end if<BR>if myseconds >= 30 then <BR>myMinutes = myMinutes + 1<BR>else<BR>myMinutes = myminutes<BR>end if<BR>getTime = myMinutes & ":" & mySeconds<BR>End function<BR><BR>&#037;&#062;<BR><BR>&#060;html><BR >&#060;head><BR>&#060;title>Untitled Document&#060;/title><BR>&#060;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><BR>&#060;/head><BR><BR>&#060;body bgcolor="#FFFFFF"><BR>&#060;p>&nbsp;&#060;/p><BR>&#060;p>you initially signed on at: &#060;% response.write(Request.Form("time1"))&#037;&#062; <BR> &#060;input type="hidden" name="time22" value=&#060;%response.write(Request.Form("time1")) &#037;&#062; maxlength="20" size="20"><BR>&#060;/p><BR>&#060;p>you signed off at: &#060;% response.write(my_date)&#037;&#062; <BR> &#060;input type="hidden" name="time2" value=&#060;% response.write(my_date)&#037;&#062; maxlength="20" size="20"><BR>&#060;/p><BR>&#060;p>for a total of: &#060;%=getTime(difference)&#037;&#062; &#060;/p><BR>&#060;/body><BR>&#060;/html>

  2. #2
    Joseph Hatcher Guest

    Default RE: another great challenge for all you asp gurus

    Hello, I have not tried any of this. I have just looked at the code and this is all theory. <BR><BR>First off, you say "the code below puts out the result as hh:mm:ss". I think it puts out mm:ss for it to do what you say the following line would have to be changed.<BR><BR>old-way<BR>getTime = myMinutes & ":" & mySeconds<BR><BR>new-way<BR>getTime = myHours & ":" & myMinutes & ":" & mySeconds<BR><BR>Now to answer your question. If it was me I would start over and write new code but if you wanted to modify this code there is many different ways to do this. One way is to change one line<BR><BR>old-way<BR>getTime = myMinutes & ":" & mySeconds<BR><BR>new-way<BR>getTime = myHours*60 + myMinutes<BR><BR>Hope my theory is correct.<BR>

  3. #3
    Join Date
    Dec 1969
    Posts
    144

    Default RE: another great challenge for all you asp gurus

    your theory is correct, thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •