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
 General SQL Server Forums
 New to SQL Server Programming
 Converting column

Author  Topic 

JJ297
Aged Yak Warrior

940 Posts

Posted - 2010-10-18 : 10:22:37
I have a table that has a field FLG_CDT char(8)

The date in that field is set up as 20100408

I would like to convert that date to 08/04/2010.

I have tons of data in that column so I added another column and called it FLGDte datetime. I need help writing a querty to get FLG_CDT converted to datetime and placed in the FLGDte field. Is that possible?


Here's the table

CREATE TABLE [dbo].[Test1](
[COSSN] [char](6) NOT NULL,
[FLG_CDT] [char](8) NOT NULL,
[AGED_ALIEN_RSW] [char](1) NULL,
[MFT_POSN1_CD] [char](1) NOT NULL,
[FO] [varchar](3) NOT NULL
) ON [PRIMARY]

GO

I didn't add the FLGDte field yet just in case you create the table and insert the values I have for you.


insert into test1
select '159746', '20100408', 'Y', 'B', '230' union all
select '122256', '20100308', 'Y', 'B', '200' union all
select '125556', '20100208', 'Y', 'B', '930'

Thanks so much

JJ297
Aged Yak Warrior

940 Posts

Posted - 2010-10-18 : 10:47:58
Never mind this worked for me:


I added the FLGDte column and made it datetime and ran this query:

update t16pendall
set FLGDte = FLG_CDT
Go to Top of Page
   

- Advertisement -