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 'yyyy-mm-dd' to 'dd/mm/yyyy'

Author  Topic 

Dan27
Starting Member

3 Posts

Posted - 2014-09-30 : 05:27:31
Hello

Hoping someone can help. I have a date and time field in the following format dd/mm/yyyy hh:mm:ss:mmmm

I only want to retrieve the date in the following format dd/mm/yyyy

When I use the following though it retreives it in yyyy-mm-dd format.

SELECT CAST(DateTime AS Date) AS 'Date'

Does anyone kinow how to get this into dd/mm/yyyy format?

Thanks in advance

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2014-09-30 : 05:31:04
can you try this
select Convert(varchar(10),CONVERT(date,YourDateColumn,106),103)

Javeed Ahmed
Go to Top of Page

Dan27
Starting Member

3 Posts

Posted - 2014-09-30 : 05:36:58
That works great. Saves me so much time.

Thanks so much
Go to Top of Page

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2014-09-30 : 05:37:31
welcome :)

Javeed Ahmed
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2014-09-30 : 08:23:11
The format matters only if you want to display it. If you use front end application do this format there

Madhivanan

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

- Advertisement -