Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Converting from a text date to datetime

Author  Topic 

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2006-11-01 : 16:38:36
I am having much difficulty changeing a text date in ddmmyyyy format to a sql datetime format.

The ddmmyyyy dates are all coming from a access db that I am importing into sql. Everything I tried does not recognize the correct format
I have tried both the following and they are not correctly converting the way I need.

CONVERT(datetime,a.[thru date], 103)
CONVERT(datetime,a.[thru date], 104)

Any help would be appriciated

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-11-01 : 16:52:45
If your format is 31122006, try it this way to convert to the universal YYYYMMDD format.


Convert(datetime,
substring( MyDate, 5, 4 )+
substring( MyDate, 3, 2 )+
substring( MyDate, 1, 2 ) )


CODO ERGO SUM
Go to Top of Page
   

- Advertisement -