Can I subtract one time from another?

Results 1 to 4 of 4

Thread: Can I subtract one time from another?

  1. #1
    Join Date
    Dec 1969

    Default Can I subtract one time from another?

    I would like to subtract one time from another to find out how many long it is until that time gets here. Is that possible? If so , how do the times need to be formatted?

  2. #2
    sampath Guest

    Default RE: Can I subtract one time from another?

    I know one way of doing in Javascript .may be you can use it in implementing in ASp with related functions in VBscript.<BR>Use date function and assign the value to some variables.say var1,var2<BR><BR>then you can get the differencein time by var1.getTime() - var2.getTime()and assign again to some variable and capture the value.<BR>This logic may be useful using VBScript as it only the matter of separate function in VBSript.<BR><BR>

  3. #3
    Ed Armelino Guest

    Default RE: Can I subtract one time from another?

    This is god-awful ugly, but i didn&#039t want to work any harder to use anything less. i called two time values (rs(3), which is later and rs(2), which is earlier. these originally were of the value mm/dd/yyyy hh:mm:ss, (i could&#039ve used the FormatDateTime function) and subtracted one from the other with this mess:<BR>-----------------------------------------<BR>iSecond = DateDiff("s", rs(2), rs(3)) &#039seconds...<BR><BR>iMinute = int(iSecond/60) <BR>iHour = int(iMinute/60)<BR>iSecond = Cint(((iSecond/60) - (iMinute)) * 60)<BR>If iHour &#062; 0 Then iMinute = Cint((iHour * 60) - iMinute)<BR>&#039iSecond = Cint(iSecond * 60) <BR>If iSecond &#060; 10 Then iSecond = "0" & iSecond<BR>If iMinute &#060; 0 Then iMinute = (iMinute * (-1))<BR>If iMinute &#060; 10 Then iMinute = "0" & iMinute<BR>If iHour &#060; 10 Then iHour = "0" & iHour<BR><BR>&#060;% and then.....<BR>response.write(iHour & ":" & iMinute & ":" & iSecond)<BR>-----------------------------------------<BR><BR><BR>there&#039s got to be a simpler and easier way, and i&#039d love for someone to email it to me at .<BR><BR>hope that helps for now<BR>

  4. #4
    Join Date
    Dec 1969

    Default RE: Can I subtract one time from another?

    Oh my God...<BR><BR>Did it occur to you to take a quick look at a VBScript reference of any kind? There a specific functions for doing date arithmetic and for extracting parts of dates and times. You&#039ve just re-invented the wheel!<BR><BR>Dunc

Posting Permissions

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