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
 Date Format- 01 June

Author  Topic 

shanmugaraj
Posting Yak Master

219 Posts

Posted - 2009-05-28 : 07:41:42
Hi,
I want to display the date in the format of 01 June.
From the below query , the date is displayed as 1 June.

SELECT CAST(DAY(GETDATE()+4) AS VARCHAR(2)) + ' ' + DATENAME(MM, GETDATE()+4) AS [DD Month]

Kindly help me. Thanks in advance

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-28 : 07:44:52
[code]SELECT CONVERT(CHAR(2), GETDATE(), 106) + ' ' + DATENAME(MONTH, GETDATE()) AS [DD Month][/code]


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

shanmugaraj
Posting Yak Master

219 Posts

Posted - 2009-05-28 : 07:48:52
quote:
Originally posted by Peso

SELECT	CONVERT(CHAR(2), GETDATE(), 106) + ' ' + DATENAME(MONTH, GETDATE()) AS [DD Month]



E 12°55'05.63"
N 56°04'39.26"





Thanks a lot for ur reply :)
ur looking smart
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-28 : 08:08:14
I have to admit I got help from Books Online.

Thank you.


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-05-28 : 08:27:16
quote:
Originally posted by shanmugaraj

Hi,
I want to display the date in the format of 01 June.
From the below query , the date is displayed as 1 June.

SELECT CAST(DAY(GETDATE()+4) AS VARCHAR(2)) + ' ' + DATENAME(MM, GETDATE()+4) AS [DD Month]

Kindly help me. Thanks in advance


But note that if you want to show dates in front end application, you should use format function there


Madhivanan

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

- Advertisement -