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
 date format: yyymmdd

Author  Topic 

kidaduo
Starting Member

45 Posts

Posted - 2008-03-25 : 10:58:46
Hellow.

Got the following data: 03/24/20080000565172. The first 10 digit is the date. I need to pull the date in the following format- 20080324 (yyymmdd) from 03/24/20080000565172 data-- how do u do

Thk

Josephine

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-03-25 : 11:15:28
SELECT SUBSTRING(Col1, 7, 4) + SUBSTRING(Col1, 1, 2) + SUBSTRING(Col1, 4, 2)
FROM Table1


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

kidaduo
Starting Member

45 Posts

Posted - 2008-03-25 : 11:27:09
Perfect. Thank for your help

quote:
Originally posted by Peso

SELECT SUBSTRING(Col1, 7, 4) + SUBSTRING(Col1, 1, 2) + SUBSTRING(Col1, 4, 2)
FROM Table1


E 12°55'05.25"
N 56°04'39.16"




Josephine
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-04-02 : 06:31:23
or

select convert(varchar(8),cast(left(col,10) as datetime),112) from your_table

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2008-04-02 : 06:34:46
quote:
Originally posted by madhivanan

or

select convert(varchar(8),cast(left(col,10) as datetime),112) from your_table

Madhivanan

Failing to plan is Planning to fail


Think this question is already answered.
And that won't work necessarily.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-02 : 11:32:32
Well, Madhi has been occupied lately



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -