4
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")

如何以“yyyy/mm/dd hh:mm:ss”格式减去两个日期?我尝试了上述两种方法,但都不起作用

4

2 回答 2

6
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
于 2012-06-28T22:08:55.950 回答
0

好吧,我是一个简单的丹麦人,我喜欢简单,所以我就这样做了:

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
于 2013-05-29T23:31:45.300 回答