Convert text to date

  • Thread starter Thread starter scubadiver
  • Start date Start date
S

scubadiver

Hello,

I am trying to link to a text file. I was having trouble converting 20011975
into a date/time format but it wasn't working. So I formatted the field as a
text file. I have tried converting this to 20/01/1975 in a query but it comes
out with errors and wierd dates.

I've had a look at the other messages and had a go but no go.

thanks
 
Regardless of how your dates are displayed either by formatting or based on
regional settings, all date functions exppect a month day year format. To
convert your string to a date field:

strTextDate = "20011975"
SomeDate = DateSerial(Clng(Right(strTextDAte,4)),
Clng(Mid(strTextDate,3,2)), Clng(Left(strTextDAte,2)))
 
Brilliant!

Klatuu said:
Regardless of how your dates are displayed either by formatting or based on
regional settings, all date functions exppect a month day year format. To
convert your string to a date field:

strTextDate = "20011975"
SomeDate = DateSerial(Clng(Right(strTextDAte,4)),
Clng(Mid(strTextDate,3,2)), Clng(Left(strTextDAte,2)))
 
Back
Top