Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    May 2002
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    date/time field calculation (Access 2000)

    Trying to figure out how to calculate number of hours have passed between two fields.
    The fields contain both date and time. The field data looks like this: 4/21/02 10:03:21 AM

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 31 Times in 31 Posts

    Re: date/time field calculation (Access 2000)

    Date/time values are stored as number, with the integer part representing the number of days since 12/30/1899. The fractional part represents time since Midnight.
    So if you subtract two date fields, the result is the number of days between them. To convert to hours, multiply by 24.
    Example:
    StartTime is 4/21/02 10:00 AM
    EndTime is 4/21/02 7:00PM
    EndTime - StartTime = 0.375
    (EndTime - StartTime) * 24 = 9, i.e. the number of hours between the times.

    You can also use the DateDiff function:
    DateDiff("h";[StartTime];[EndTime])

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,469
    Thanks
    1
    Thanked 40 Times in 39 Posts

    Re: date/time field calculation (Access 2000)

    You didn't say if you wanted the result in whole hours or not. If so, you can use the DateDiff function.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

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