Snippet
' Written by Sanchit Karve
' born2c0de
' born2c0de@hotmail.com
Public Function StrToDate(ByVal strng As String) As String
Dim d As Integer
Dim m As Byte
Dim Y As Integer
Dim i As Integer
Dim tmp As String, tmp1 As String
strng = Trim(strng)
d = Int(Val(strng))
Y = Val(Right(strng, 4))
strng = Mid(strng, 1, Len(strng) - 5)
For i = Len(strng) To 1 Step -1
If Asc(Mid(strng, i, 1)) >= 65 Then tmp = tmp + Mid(strng, i, 1) Else Exit For
Next i
tmp = StrReverse(tmp)
tmp = Left(tmp, 3)
tmp1 = Trim(tmp1)
tmp1 = IIf(d < 10, "0" + Trim(Str(d)), Trim(Str(d)))
tmp1 = Trim(tmp1) + "-" + UCase(tmp) + "-" + Trim(Str(Y))
StrToDate = tmp1
End Function
' EXAMPLE
'
' Msgbox StrToDate("6 February 2005")
Copy & Paste
|