Link to home
Start Free TrialLog in
Avatar of tranvangiang17
tranvangiang17

asked on

How to write a SQL Statement which can convert a 8-Char “TEXT” Field into a ”DATETIME” Field.

Please help me to write a SQL SERVER 2005 statement which can convert a 8-Char “TEXT” Field into”DATETIME” Field.


To simplify the issue; say my SQL DB has a single table called “TestTbl;” and this ‘TestTbl” has only one 8-Char text field, namely “DATE” with the data (3 records) as follows:

DATE        (originally as 8-Char Text)

20111017
20110830
20110725

The requested query statement will give the output after its execution as follows:


DATE         (now is simple "datetime" field)

10/17/2011
0-8/30/2011
07/25/2011

Thanks.


van
Avatar of tranvangiang17
tranvangiang17

ASKER

Typo correction:

Output Data should read as follows instead:


DATE         (now is simple "datetime" field)

10/17/2011
08/30/2011
07/25/2011


Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Dear mwvisa1,

It is working just fine.   You are my hero.

Thanks.

Van