vb 关于时间转字符串

2024-12-04 16:18:48
推荐回答(4个)
回答(1):

Dim S As Date
S = #2013-05-23 15:00:00# '日期型变量在赋值时,前后要加#
shijian = Format(S, "YYYYMMDDHHmmSS")

回答(2):

    Dim s As Date
    s = Now
    shijian = Format(s, "yyyymmddhhmmss")

 

    Dim s As Date
    s = #5/23/2013 3:00:00 PM#
    shijian = Format(s, "yyyymmddhhmmss")

回答(3):

Dim s, hr, sc, hor As String
Dim mydate As Date, shici As Date
s = "20130624050000"
hr = 1
mydate = Format(s, "####-##-## ##:##:##")
shici = DateAdd("h", hr, CDate(mydate))
hor = Format(shici, "YYYYMMDDHHmmSS")
Debug.Print hor

回答(4):

s = "2013-05-23 15:00:00"