谢谢,网上找到下面这段代码可以一用,就是创建函数有点麻烦。
Public Function fConvertDate(strDate As String) As Date
Dim bytDay As Byte
Dim intYear As Integer
Dim strMonth As String
Dim bytMonth As Byte
bytDay = Val(Left(strDate, 2))
intYear = CInt(Mid(strDate, 6, 4))
strMonth = UCase$(Mid(strDate, 3, 3))
bytMonth = Val(Switch(strMonth = "JAN", "1", strMonth = "FEB", "2", strMonth = "MAR", "3", _
strMonth = "APR", "4", strMonth = "MAY", "5", strMonth = "JUN", "6", strMonth = "JUL", "7", _
strMonth = "AUG", "8", strMonth = "SEP", "9", strMonth = "OCT", "10", strMonth = "NOV", "11", _
strMonth = "DEC", "12"))
fConvertDate = DateSerial(intYear, bytMonth, bytDay)
End Function
|