Click here to Skip to main content
16,004,782 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this date Wednesday, January 18, 2012 formate
Posted

SQL doesn't have anything for generating that kind of date format automatically, the CONVERT function is restricted in the number of styles it can cope with: http://www.w3schools.com/sql/func_convert.asp[^]

If you want that specific format, then you will either have to write your own function (probably using CONVERT a couple of times and then extracting the substrings) or do it in you presentation software (which is likely to have a better range of formats available)
 
Share this answer
 
Since SQL Server 2012, there is an inbuilt function called FORMAT() is there for this kind of requirement.
Example:
SQL
SELECT FORMAT(GETDATE(), 'D') --Thursday, January 8, 2015

Reference-
SQL Server's FORMAT() function[^]

For SQL Server version earlier than 2012, you can create your own work around like

SQL
SELECT DATENAME(WEEKDAY,GETDATE())+', '+DATENAME(MONTH,GETDATE())+' '+DATENAME(DD,GETDATE())+', '+DATENAME(YEAR,GETDATE()) --Thursday, January 8, 2015

You can create an user defined function for this for reuse of the code. In case you need help on that, please let me know.

Hope that helps :)
 
Share this answer
 
v2
As Griff said,sql does not have any date format like (Wednesday, January 18, 2012).
but you can try like this,
SQL
declare @Day_of_week nvarchar(max)='18 Jan 2012';
select DATENAME(WEEKDAY,@Day_of_week)+','+@Day_of_week as Day_of_Week
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900