Time fields

Results 1 to 3 of 3

Thread: Time fields

  1. #1
    Join Date
    Dec 1969

    Default Time fields

    I have 3 values from a table in access, all in time format (i.e "2:29:03 PM").<BR>I want to add them together & divide them by 3 to get the average.<BR><BR>How do I do this in VBScript?<BR>(I tried the obvious way of adding & dividing, but the result is not in the Time format)

  2. #2
    Join Date
    Dec 1969

    Default RE: Time fields

    I can suggest one method but its a little long maybe not little but might work for u<BR><BR>add the time<BR>convert it into number of days<BR>divide it by 3<BR>convert back to hours<BR><BR>see if it works

  3. #3
    Join Date
    Dec 1969

    Default Try this

    I&#039;ve used 2 values cus it&#039;s easy to see that the average between 02:00 and 02:30 = 02:15..<BR><BR> dtmA="02:00"<BR> dtmB="02:30"<BR> <BR> mins=datepart("h",dtmA)*60+datepart("n",dtmA)<BR> mins=mins+datepart("h",dtmB)*60+datepart("n",dtmB) <BR> mins=mins/2<BR> <BR> c=timeserial(0,mins,0)<BR> alert (c)<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