dbTalk Databases Forums  

Format for six character date

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Format for six character date in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
robboll
 
Posts: n/a

Default Format for six character date - 09-04-2007 , 12:56 AM






Using SQL Server 2000 in a view, if the data is Char and six
characters like: 081564

How do I convert it to a date that looks like: 08/15/1964 and is a
date.

I am trying:

CONVERT (varchar, SUBSTRING(Col005, 1, 2) + '/' + SUBSTRING(Col005, 3,
2) + '/' + SUBSTRING(Col005, 5, 2), 112)

but it returns 08/15/64. Anyone tell me what I'm doing wrong.

Thanks in advance!

RBolling


Reply With Quote
  #2  
Old   
Shiju Samuel
 
Posts: n/a

Default Re: Format for six character date - 09-04-2007 , 12:25 PM






This should work

select
CONVERT (varchar, cast(SUBSTRING('081564' , 1, 2) +
'/' + SUBSTRING('081564' , 3,
2) + '/' + SUBSTRING('081564' , 5, 2) as datetime), 101)

-
Shiju


On Sep 4, 10:56 am, robboll <robb... (AT) hotmail (DOT) com> wrote:
Quote:
Using SQL Server 2000 in a view, if the data is Char and six
characters like: 081564

How do I convert it to a date that looks like: 08/15/1964 and is a
date.

I am trying:

CONVERT (varchar, SUBSTRING(Col005, 1, 2) + '/' + SUBSTRING(Col005, 3,
2) + '/' + SUBSTRING(Col005, 5, 2), 112)

but it returns 08/15/64. Anyone tell me what I'm doing wrong.

Thanks in advance!

RBolling



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.