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
 need to get the date format in dd-MM-yyyy

Author  Topic 

aoriju
Posting Yak Master

156 Posts

Posted - 2013-08-05 : 03:57:22

DECLARE @t DATETIME

SET @t ='2013-05-17';

i need to get the date format in
dd-MM-yyyy

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-08-05 : 04:14:55
this is a presentation issue and you should be trying to do this at front end
If no other way, use query like this


DECLARE @t DATETIME

SET @t ='2013-05-17'

SELECT CONVERT(varchar(11),@t,105)



if SQL 2012 use


SELECT FORMAT(@t, 'dd-MM-yyyy')


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2013-08-18 : 12:40:37
If you can't avoid formatting in SQL, use CONVERT function because FORMAT is very slow http://beyondrelational.com/modules/2/blogs/70/Posts/17608/different-ways-to-remove-time-part-from-datetime-values-faster-methods.aspx

Madhivanan

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

- Advertisement -