Home >> FAQs/Tutorials >> SQL Server FAQ
SQL Server FAQ - Getting Month and Weekday Names from DATATIME Values
(Continued from previous topic...)
How To Get Month and Weekday Names from DATETIME Values?
In DATETIME values, the month part and weekday part have names.
You can use the DATENAME() function to get the month name and weekday name from a DATETIME value
in the following format:
DATENAME(datepart, date) returns NVARCHAR:
"date" - the input date
"datepart" - "month" or "weekday"
Here is a simple example:
DECLARE @submit_date DATETIME;
SET @submit_date = '2007-05-19 16:10:41.403';
SELECT 'Posted in the month of '
+ DATENAME(month, @submit_date)
+ ' on a '+DATENAME(weekday, @submit_date);
Posted in the month of May on a Saturday
(Continued on next topic...)
- How To Add or Remove Days on Date and Time Values?
- Can Date and Time Values Be Converted into Integers?
- Can Integers Be Converted into Date and Time Values?
- Are DATETIME and NUMERIC Values Convertible?
- Can a DATETIME Value Be Subtracted from Another DATETIME Value?
- What Are the Date and Time Functions Supported by SQL Server 2005?
- How To Increment or Decrement Parts of DATETIME Values?
- How To Use DATEADD() Function?
- How To Calculate DATETIME Value Differences Using the DATEDIFF() Function?
- How To Calculate Age in Days, Hours and Minutes?
- How To Get Month and Weekday Names from DATETIME Values?
- How To Get Parts of DATETIME Values as Integers?
- How To Get Year, Month and Day Out of DATETIME Values?
- What Is the Difference Between GETDATE() and GETUTCDATE()?
- How To Format Time Zone in +/-hh:mm Format?
- How To Format DATETIME Values to Strings with the CONVERT() Function?
- How To Truncate DATETIME Values to Dates without Time?
- How To Set Different Parts of a DATETIME Value?