如何将字符串mmmdd,yyyy(Apr16,2015)转换为日期格式? Cdate和datevalue在这里不起作用 提前谢谢。
答案 0 :(得分:3)
"Apr 16 2015"
是可解析的:
dateStr = "Apr16,2015"
?cdate(left$(dateStr, 3) & " " & mid$(dateStr, 4, 2) & " " & right$(dateStr, 4))
16/04/2015
答案 1 :(得分:0)
我经常使用以下方法。
dateStr = "Apr16,2015"
Yr = right(dateStr,4)
Mnth = left(dateStr,3)
Dy = mid(dateStr,4,5)
x = DateSerial(Yr,Mnth,Dy)
或
x = DateSerial(Year(dateStr), Month(dateStr), Day(dateStr ))