VBA string with milliseconds to date

前端 未结 5 762
无人共我
无人共我 2021-01-19 21:38

I have a string in the form \"yyyy-mm-dd hh:mm:ss.mmm\" (where the end is milliseconds)

I\'d like to convert it to a number, preferably a Date

5条回答
  •  梦谈多话
    2021-01-19 22:39

    Use the Left$ function to trim the decimal point and milliseconds:

    Dim dateValue As Date
    dateValue = CDate(Left$("2017-12-23 10:29:15.223", 19))
    

提交回复
热议问题