Access將秒數轉化爲時分秒00:00:00的格式

2017-12-29 16:46:00
Trynew
轉貼
1018

有時我們在其他軟件中導齣得到一串秒數。希望把改秒數轉化爲時分秒00:00:00的格式

這裡需要自定義一箇函數去轉換

Function SecToTime(dblSecond As Double) As String
    SecToTime = Format((Int(dblSecond) / 60 / 60 / 24), "HH:MM:SS")
    If Int(dblSecond) <> dblSecond Then SecToTime = SecToTime & Round(dblSecond - Int(dblSecond), 2)
    SecToTime = IIf(Left(SecToTime, 6) = "00:00:", Mid(SecToTime, 7), IIf(Left(SecToTime, 3) = "00:", Mid(SecToTime, 4), SecToTime))
End Function



在窗體中調用該函數

Private Sub Command4_Click()
    Me.Text2 = SecToTime(Me.Text0)
End Sub



效果圖:

    分享