Hello,
I am trying to calculate the time difference between two times defined by date and time
I need some help since, the result I get does not seem to be correct.
Please c]see code below.
What am I missing?
Thank you
I am trying to calculate the time difference between two times defined by date and time
I need some help since, the result I get does not seem to be correct.
Please c]see code below.
What am I missing?
Thank you
VBA Code:
Sub time_difference()
D1 = "08/26/23"
T1 = "13:19"
D2 = "08/27/23"
T2 = "04:48"
dt1 = D1 + " " + T1
dt2 = D2 + " " + T2
DIF_S = DateDiff("n", dt1, dt2)
DIF_M = Int(DIF_S / 60)
DIF_S = DIF_S - DIF_M * 60
DIF_H = Int(DIF_M / 60)
DIF_M = DIF_M - DIF_H * 60
Debug.Print i, D2, T2, D1, T1, DateDiff("n", dt1, dt2), DIF_H, DIF_M, DIF_S
end sub