A better CDate for VB6

后端 未结 8 706
悲哀的现实
悲哀的现实 2020-12-21 05:43

We have a a VB6 app (in a COM component) which uses CDate() to take a string and cast it to a Date, for storing in a database.

Depending on if we want the applicatio

8条回答
  •  [愿得一人]
    2020-12-21 06:21

    DateAdd accepts a wide variety of inputs and outputs in the correct format.

    ThisLine =  "Tuesday, September 04, 2012 2:02 PM"
    
    i = InStr(ThisLine, ",")  ' get rid of the leading day
    
    If i > 0 Then
         TempResult = Trim(Right$(ThisLine, Len(ThisLine) - i))
    end if
    
    TempResult = DateAdd("s", 0, TempResult)
    

提交回复
热议问题