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 a date format

Author  Topic 

Trininole
Yak Posting Veteran

83 Posts

Posted - 2010-09-30 : 11:35:02
how to convert a date with a "datetime" datatype to a date without the times listed? For example how to convert the date format "2009-05-29 10:10:00" to just "2009-05-29"?

Roger DeFour

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2010-09-30 : 11:46:28
In which version? In 2008, there is a DATE datatype, in all other versions, either complete this in the front end or convert the date to varchar(10) if you do not have a front end reporting tool.

To just get rid of the time (but it will still show the time elements:

SELECT DATEADD(dd,0,DATEDIFF(dd,0,'2009-05-29 10:10:00'))
Go to Top of Page

Trininole
Yak Posting Veteran

83 Posts

Posted - 2010-09-30 : 11:54:36
well i am using the convert(smalldatetime,convert(varchar(10),max_serv_date_intrvl, 112)) to have the max_serv_date_intrvl enlist the date itself without the time but it is still enlisting the time, how do i fix that?

Roger DeFour
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-09-30 : 11:57:56
and keep in mind if you're making it varchar then it make date manipulations really difficult.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-10-01 : 06:07:58
quote:
Originally posted by Trininole

how to convert a date with a "datetime" datatype to a date without the times listed? For example how to convert the date format "2009-05-29 10:10:00" to just "2009-05-29"?

Roger DeFour


If you use front end application, do formation there

Madhivanan

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

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2010-12-13 : 01:15:16
use this.
SELECT CONVERT(VARCHAR,GETDATE(),103)
Go to Top of Page
   

- Advertisement -