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

Author  Topic 

tyekhan786
Starting Member

9 Posts

Posted - 2014-03-29 : 08:48:07
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

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2014-03-29 : 09:24:01
do the formatting in your front end application


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2014-03-29 : 09:31:46
In 2012, you can CAST it to DATE

SELECT CAST(datecol as DATE) from table

Madhivanan

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

tyekhan786
Starting Member

9 Posts

Posted - 2014-03-29 : 10:52:03
sorry i have 2008


quote:
Originally posted by madhivanan

In 2012, you can CAST it to DATE

SELECT CAST(datecol as DATE) from table

Madhivanan

Failing to plan is Planning to fail

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2014-03-29 : 13:12:53
quote:
Originally posted by tyekhan786

sorry i have 2008


quote:
Originally posted by madhivanan

In 2012, you can CAST it to DATE

SELECT CAST(datecol as DATE) from table

Madhivanan

Failing to plan is Planning to fail




But you have posted this question in 2012 forum. Well. Use the following

SELECT dateadd(day,datediff(day,0,datecol),0) from table



Madhivanan

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

- Advertisement -