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 2008 Forums
 Transact-SQL (2008)
 Date Format

Author  Topic 

tyekhan786
Starting Member

9 Posts

Posted - 2014-03-29 : 10:52:33
I need to change the Datetime field to Data only.

Current format -- 28/09/2013 12:59:20

Format wanted --- 2013-09-28

Date only in YYYY-MM-DD

Thanks

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2014-03-29 : 13:13:28
See the answers here at http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=193455

Madhivanan

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

ScottPletcher
Aged Yak Warrior

550 Posts

Posted - 2014-03-31 : 13:26:40
SELECT CONVERT(varchar(8), datetime_column, 120) AS date_only
Go to Top of Page

sqlsaga
Yak Posting Veteran

93 Posts

Posted - 2014-03-31 : 15:38:24
Input you passed is not in the date time format...

DECLARE @Input DATETIME= '2013/09/28 12:59:20'
SELECT CONVERT(DATE, @Input)
SELECT CONVERT(VARCHAR(10), @Input, 120)


Visit www.sqlsaga.com for more t-sql code snippets and BI related how to articles.
Go to Top of Page
   

- Advertisement -