How can the date be formatted as Month dd, yyyy?

Feedback


Solution 1:

This website offers a wide range of SQL formats and useful date hacks.

Please refer to the following link for tips on date formats: http://www.sql-server-helper.com/tips/date-formats.aspx.

And below is their request in the format of (Month dd, yyy):

SELECT DATENAME(MM, GETDATE()) + RIGHT(CONVERT(VARCHAR(12), GETDATE(), 107), 9) AS [Month DD, YYYY]


Solution 2:


The

DATENAME

function can be utilized to combine the pieces as SQL Server offers a restricted range of date formats.

SELECT DATENAME(MM, GETDATE()) + ' ' + 
       DATENAME(DD, GETDATE()) + ', ' + 
       DATENAME(YYYY, GETDATE())
       AS 'Formatted Date'

In most cases, it is advisable to keep dates in their date format instead of converting them to strings. Conversion to strings should only be done in the display layer, such as a website, report, or application, where there are more formatting options available. Converting dates to strings can result in the loss of functionality for date calculations, sorting, and other operations.


Solution 3:

SELECT DATENAME(MM, GETDATE()) + RIGHT(CONVERT(VARCHAR(12), GETDATE(), 107), 9) AS [Month DD, YYYY]

Frequently Asked Questions