Subtract VBA Subtract Date and Time

Dim dtmStart As Date, dtmEnd As Date, dblDuration As Double dtmStart = "1900/01/01 08:10:00" dtmEnd = "1900/01/03 21:16:00" dblDuration = DateDiff("hh:mm", dtmEnd, dtmStart) 'dblDuration = dtmEnd - dtmStart MsgBox Format(dblDuration, "hh:mm") 

How to subtract two dates in the format "yyyy / mm / dd hh: mm: ss"? I tried both methods above and did not work

+4
source share
2 answers
 Sub Test() Dim dtmStart As Date, dtmEnd As Date, dblDuration As Double dtmStart = "1900/01/01 08:10:00" dtmEnd = "1900/01/03 21:16:00" dblDuration = dtmEnd - dtmStart MsgBox Application.Text(dblDuration, "[hh]:mm") End Sub 
+6
source

Well, I'm a simple Dane, and I just like it, so I just did it like this:

 Dim dtmStart As Date, dtmEnd As Date, dblDuration As Date Start: 'STARTTIME dtmStart = Time Slut: 'SLUTTIDEN dtmEnd = Time dblDuration = dtmEnd - dtmStart Debug.Print "Modul 1 Slut " & Time; " Run = "; dblDuration 
0
source

All Articles