Subtract dates > 24hrs and display as days:hours:minutes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neelsfer
    Contributor
    • Oct 2010
    • 547

    Subtract dates > 24hrs and display as days:hours:minutes

    I try and subtract the admission and discharge dates of patients at a hospital.
    discharge = discharge date (end) / admit = admission date (start)
    I use the following code and it works but the layout/format is not what i require.
    Code:
    PatientDays: Int([discharge]-[admit]) & Format([discharge]-[admit],""" days ""h"" hrs, ""n"" min""")
    i get this result
    Code:
    2 days 10 hrs, 0 min
    i would prefer it to be like this:
    Code:
    02:10:00
    Any suggestions pls?
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    You should try to understand how the function 'Format()' works.
    (see: the manual)

    next line might have the solution:
    Code:
    Int(discharge - admit) & Format([discharge] - [admit], """:""h"":""n"" """)

    Comment

    • neelsfer
      Contributor
      • Oct 2010
      • 547

      #3
      Thx Luuk it works 100%. I have been trying all sorts of variations.

      Comment

      Working...