Results 1 to 3 of 3
  1. #1
    cfrankling is offline Novice
    Windows 10 Office 365
    Join Date
    Aug 2021
    Posts
    11

    Question Time difference

    Hello,



    Im trying to calculate time difference between StartTime and EndTime, if both times are within the 24hr period, I have no issues coming up with the difference by just subtracting, the issues comes when the EndTime happens to be the next day, for example:

    StartTime 22:00 Endtime 01:00 (next day)

    I've tried the following code in a "text box control source" that I found on the net but in my particular case I end up with a neg time.

    =DateDiff("n",[CheckInTime],[DispatchedTime])\60 & Format(DateDiff("n",[CheckInTime],[DispatchedTime]) Mod 60,"\:00")

    Any suggestions would be greatly appreciated.

    Thanks
    Carlos

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,941
    Assuming your time is just time and does not include a date in the underlying data then try


    endtime+abs(endtime<starttime) - starttime

  3. #3
    cfrankling is offline Novice
    Windows 10 Office 365
    Join Date
    Aug 2021
    Posts
    11
    CJ_London, I owe you a beer, your suggestion works perfect.

    Thank you!

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

Similar Threads

  1. Replies: 7
    Last Post: 08-23-2019, 04:51 PM
  2. Replies: 5
    Last Post: 07-24-2014, 07:54 AM
  3. Time Difference
    By jlclark4 in forum Queries
    Replies: 4
    Last Post: 10-13-2011, 09:23 AM
  4. HELP! Elapsed Time Difference
    By accessineedhelp in forum Access
    Replies: 5
    Last Post: 08-31-2011, 06:00 PM
  5. Time difference
    By jguidry in forum Programming
    Replies: 1
    Last Post: 11-15-2008, 12:41 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