Access将秒数转化为时分秒00:00:00的格式

2017-12-29 16:46:00
Trynew
转贴
520

有时我们在其他软件中导出得到一串秒数。希望把改秒数转化为时分秒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



效果图:

    分享