Results 1 to 4 of 4
  1. #1
    Hammer is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    4

    Time Expressions in queries

    Could somebody point me in the right direction with this please as I'm a bit of a novice.



    I am trying to create a query to work out the number of hours worked. I have a start time & a finish time in a table, set as date / time. I have built the query but the answer does not come out as a time

    Start time: 09:00
    Finish time: 18:00
    hours worked shows as 0.375, how do I convert this to show 9 hrs?
    I've tried multiplying by 24 but i then get dates and allsort appear!!!

    Many Thanks

  2. #2
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    How are you doing the calculation?

    What should happen if they start at 2100 and stop the next day at 0300? You should have a date somewhere...

    What you should be using is the DateDiff() function. You can have the results in seconds, minutes, hours, days, months, quarters, years, ...

    BTW, 0.375 * 24 = 9 according to my calculator. (But use the DateDiff() function )

  3. #3
    jzwp11 is offline VIP
    Windows 7 Access 2007
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    How are you currently determining the difference? Are you using the datediff() function? Does your field also include the date or just the time?

    You probably want something like this:

    (DateDiff("n",starttime,finishtime))/60

    The above expression will give you the time in hours with the number of minutes expressed as a decimal i.e. 5.5 hours

    If you want 5:30 (five hours and thirty minutes) that would require a little more manipulation of the expression.

    Which do you want?

  4. #4
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    when you use day1 - day2, the result is the time difference by day. in your example you got 0.375 day (9 hours)

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 08-04-2010, 09:35 AM
  2. Nested If Expressions
    By Lynn in forum Forms
    Replies: 5
    Last Post: 03-25-2010, 10:11 AM
  3. Combining Two DCount expressions in one
    By nmodhi in forum Forms
    Replies: 1
    Last Post: 02-26-2010, 10:49 AM
  4. Conditions / Expressions
    By Mark344 in forum Access
    Replies: 1
    Last Post: 02-19-2010, 08:15 AM
  5. Time queries
    By ddog171 in forum Queries
    Replies: 2
    Last Post: 06-04-2006, 06:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums