Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Ephrata, Washington, USA
    Posts
    683
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Date Time Conversion - Format question (2003)

    I have an expression in a query that calculates the difference between two dates/times. For example (In : 4/7/2004 11:34 am and Out: 4/9/2004 3:00 pm).

    I used the expression builder and this is my expression: Total Time: Format(DateDiff("h",[Date Deployed],[Date Recovered]),"00") & ":" & Format(DateDiff("n",[Date Deployed],[Date Recovered]) Mod 60,"00")

    The result now shows as 52:26. Seems ok. But, the user wants this displayed as a decimal number. Not as time. He said he is going to use it in a calculation, so instead of 52:26 he wants 52.(and the decimal conversion of 26).

    I looked it up in the help files, but couldn't find it. I found something for this in Excel (the Int function), but I can't figure out how to use that in Access - or if it's even possible.

    Any ideas? Thank you!

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

    Re: Date Time Conversion - Format question (2003)

    Dates and times are actually stored internally as numbers, with 1 day as unit. You can calculate the difference between two date/time values in days by subtracting them. To convert the difference to hours, multiply by the number of hours in a day, 24:

    Total Time: ([Date Recovered]-[Date Deployed])*24

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Ephrata, Washington, USA
    Posts
    683
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date Time Conversion - Format question (2003)

    Wow. Talk about over complicating things, huh? Thanks Hans. Once again.

Posting Permissions

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