標籤

2016年9月22日 星期四

[VB6] 比較日期&時間


Dim sDate_1, sDate_2 As String
Dim dDate_1, dDate_2 As Date

sDate_1 = "2016/09/20 08:10:50"
sDate_2 = "2016/09/20 08:00:50"

dDate_1 = CDate(sDate_1)
dDate_2 = CDate(sDate_2)
MsgBox DateDiff("s", dDate_1, dDate_2)

DateDiff第一個參數是Interval,作為兩個時間之間時間差的單位
有 y.m.d.h.n.s(年.月.日.時.分.秒)...等等

沒有留言:

張貼留言