Results 1 to 2 of 2

Thread: Round Time

  1. #1
    Join Date
    Apr 2008

    Unanswered: Round Time

    How would you Round a field that just has the time in recorded.

    Field= TimeIn

    If time in = 10:08

    How would you round it to the nearest .15 minutes

    So 10:08 would be rounded to 10:15

  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    do some integer mathmatics on the date time value
    this can be done using say the minute/min function

    you could examine the decimal portion of a date time field ( Access/JET stores dates and times as a single data type.. the integer part is the number of days from a sepcific date (01 Jan 1900 rings a bell), and the decimal part is the proportion of one day so .25 = 1/4 of a day eg 6 hours

    it can be done in a function

    function RoundupMinutes(mydatevalue as date) as date
    const AMinute as 1/(24*60) 'a minute in access terms is 1/24 [hours]*60 [minutes in hours]
    Dim tMinute as single
    tMinute = minute(mydatevalue)
    select case minute(mydatevalue)
    case 1 to 15: RoundupMinutes = mydatevalue + (15-tminute*aminute)
    case 16 to 30: RoundupMinutes = mydatevalue + (30-tminute*aminute)
    end select
    end function

    that should get you close to where you want to be

Posting Permissions

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