Results 1 to 15 of 15
  1. #1
    KNap is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2013
    Posts
    28

    Recording time spent


    Hi

    I have set up a case management system

    at the end of a case record you can record the amount of time spent. I think at the moment it's not recorded as a number it's as short text.. not sure why - so the firsrt question is do i need to change this to a number?

    the second question is how do I work out how much time I've spent during a date parameter? So I have created a report which lists each time spent record and I need the formula to add the time spent but in hours and minutes rather than a general number?

    Happy to correct anything that I've done wrong to achieve what I need.

    Thanks in advance

  2. #2
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,158
    If you need to do maths on a number / datetime field (Which is actually stored as a decimal number as well) then you should store the data as the correct data type.

    You can use the DateDiff() function to return a number in hours or minutes between two datetime values.
    You can then convert that to display hours and minutes if you need it.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    KNap is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2013
    Posts
    28
    Thanks for this - just so I've got it right - I need to change [Time Spent] to a general number?

    So what would the formula be to calculate the total [Time Spent] in a report footer please?

  4. #4
    KNap is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2013
    Posts
    28
    I mean converting the general number to hours and minutes?

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    You record your time values in a common unit --say minutes.
    You do your calculations knowing that:
    60 min = 1 hour

    Divide your minutes total by 60 to get Hours.

  6. #6
    KNap is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2013
    Posts
    28
    Thanks for this - however, on my report, no matter how I change the properties to display a general number with two decimal places i get a number with loads of decimal places....

    The formular i used is this:
    =sum([Time Spent]/60) & "hours"

    is there something I'm missing?

    Thanks

  7. #7
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Try

    =Round(sum([Time Spent]/60),2) & "hours"

  8. #8
    KNap is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2013
    Posts
    28
    Great - that has got the decimals down to two - thank you....

    However, the number that has come up is 10.67 - would that not be 11.07 in hours and minutes??

    So sorry to be a pain

  9. #9
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,425
    I'm kind of surprised that no one mentioned it's generally considered a bad idea to store calculations. If for example you have start and end time values as fields, you should be showing the elapsed time, not calculating and storing the result.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  10. #10
    KNap is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2013
    Posts
    28
    Ok - I'm up for all suggestions

  11. #11
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,205
    Quote Originally Posted by KNap View Post
    Great - that has got the decimals down to two - thank you....

    However, the number that has come up is 10.67 - would that not be 11.07 in hours and minutes??

    So sorry to be a pain
    No.
    10.67 hours =10 hr 40 min = 640 min
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  12. #12
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,425
    No.
    10.67 hours =10 hr 40 min = 640 min
    And the .67 is rounded?
    Mathematically it's closer to .6665

    not sure what this means or whom it's directed to
    Ok - I'm up for all suggestions
    If me and the notion of only calculating, start with a read of this:
    You can ignore the code for a stock count issue and just focus on the logic behind not storing calcs. In the end, your forms/reports just end up with unbound textboxes to calc the difference between 2 values, be they dates or whatever.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  13. #13
    KNap is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2013
    Posts
    28
    how would I go about doing that?

  14. #14
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Perhaps KNap can tll us more about the application generally.
    I did not interpret the post to be storing a calculated field - however, that may be what is going on.
    I was just showing the mechanics of calculating time duration --- hours/minutes; and Rounding.

  15. #15
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,425
    @Orange, I may have misinterpreted this
    at the end of a case record you can record the amount of time spent.
    to be a calculation done by the db when in fact, someone might just be entering 1.5 hours as a value and this
    how do I work out how much time I've spent during a date parameter
    as a calculation that will shift the manual calculation to an automated one, but still storing the result. Perhaps not.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Time spent on a record
    By leosaumure in forum Forms
    Replies: 2
    Last Post: 02-14-2018, 07:08 PM
  2. Replies: 2
    Last Post: 11-27-2017, 07:09 AM
  3. Replies: 7
    Last Post: 09-02-2014, 08:18 AM
  4. Record Time Spent Task
    By rosscortb in forum Access
    Replies: 1
    Last Post: 07-09-2014, 07:55 AM
  5. Time Spent on Activities Report
    By avarusbrightfyre in forum Reports
    Replies: 1
    Last Post: 10-14-2010, 05:02 PM

Tags for this Thread

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