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 2005 Forums
 Transact-SQL (2005)
 Get partial data in the column

Author  Topic 

gurupot
Starting Member

2 Posts

Posted - 2007-07-23 : 12:13:46
Hi,

One of the columns in my table in SQL has the following data '2003-01-31 09:03:05.303'. I would like to get only the date (2003-01-31)from this column. How would I do that.

Also I need to format this date as '20030131'.
Can anyone help how I could accomplish this.

Thanks,
Gurupot.

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-07-23 : 12:24:22
Its best to do that kind of formatting at the front end.

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-07-23 : 12:26:44
SELECT CONVERT(VARCHAR, Col1, 112)
FROM Table1


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

gurupot
Starting Member

2 Posts

Posted - 2007-07-23 : 14:49:35
Thankyou. That worked just the way I want it.
I appreciate your help with this.
Go to Top of Page
   

- Advertisement -