Convert string to date
Posted on 2004-10-24
I'm working with calendar data exported from Outlook. For some reason, Outlook exports the data as text, not a date/time variable, so I need to convert the data to date/time before I can work with it.
I tried the following:
Private Sub Clean1_Click()
Dim datStartDate2 As Date
Dim strStartDate As String
strStartDate = StartDate.Text
datStartDate2 = CDate(strStartDate)
StartDate2.Text = datStartDate
but keep coming up with a type mismatch error.
I also tried DateValue instead of CDate but still got a type mismatch error.
I've tried dim-ing datStartDate2 as Date and as Var but still get that error.