[Excel/Access VBA]「#2008-01-01#」形式の日付を「2008-01-01」に変換する方法
Function sanitizeDate(str As Variant) As Variant
If Left(str, 2) = "#2" And Right(str, 1) = "#" And Len(str) = 12 Then
sanitizeDate = Mid(str, 2, 10)
Else
sanitizeDate = str
End If
End Function
使い方
Sub test()
MsgBox sanitizeDate("#2008-01-01#")
End Sub
実行結果: 2008-01-01