Results 1 to 6 of 6
  1. #1
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232

    DateDiff value


    Hi I have a field called "arrived time and one called completed time"
    I have a field that has the following in default value.
    it works but I need it to show in the following format " hours and minutes " not just a total of minutes

    if the arrived time is 3:00am and the completed time is 4:30am than I want it to give me the default value of 1 hour 30 minutes.

    =DateDiff("n",[Arrived Time],[Completed Time])

    Thanks

  2. #2
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232
    I changed the above to

    =datediff("n",[arrived time],[completed time])/60

    so if the arrived time is 9:30am and the completed time is 2:10pm it returns the value of 4.666666666666666667 I need it to return the value of 4 hours 40 minutes

    Thanks Angie

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Here is an expression... Note that if the time crosses midnight, you will get unexpected results.
    Code:
    =int(datediff("n",[arrived time],[completed time])/60) & " hours " & datediff("n",[arrived time],[completed time]) Mod 60 & " minutes"

    NOTE: It is not considered a good practice to have spaces in object names (especially field names).
    Use only letters and numbers (exception is the underscore). Also do not use punctuation or special characters in object names.

  4. #4
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232
    =DateDiff("n",[Arrived Time],[Completed Time])\60 & Format(DateDiff("n",[Arrived Time],[Completed Time]) Mod 60,"\:00")

    I Figured it out and the above works great incase someone else has the same problem. Angie

  5. #5
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232
    Thanks yours is better than what I came up with thanks so much (using yours)
    Thanks again

  6. #6
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Happy to help....

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

Similar Threads

  1. DateDiff
    By TheHarleygirl2005 in forum Access
    Replies: 2
    Last Post: 07-09-2015, 11:44 AM
  2. DateDiff
    By mphynson44 in forum Queries
    Replies: 3
    Last Post: 02-27-2014, 07:28 PM
  3. DateDiff Help
    By iProRyan in forum Forms
    Replies: 1
    Last Post: 03-29-2012, 03:57 AM
  4. Datediff()
    By st1300 in forum Programming
    Replies: 6
    Last Post: 12-08-2011, 05:58 PM
  5. Datediff
    By greggue in forum Queries
    Replies: 2
    Last Post: 08-13-2010, 03:53 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