Collections:
Getting Month and Weekday Names from DATATIME Values in SQL Server
How To Get Month and Weekday Names from DATETIME Values in SQL Server Transact-SQL?
✍: FYIcenter.com
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); GO Posted in the month of May on a Saturday
⇒ Getting Parts of DATETIME Values as Integers in SQL Server
⇐ Calculating Age in Days, Hours and Minutes in SQL Server
⇑ Date/Time Operations and Functions in SQL Server Transact-SQL
2017-02-14, 1399🔥, 0💬
Popular Posts:
What is sqlservr.exe - Process - SQL Server (SQLEX?PRESS) in SQL Server? Process sqlservr.exe is the...
What Are the Underflow and Overflow Behaviors on FLOAT Literals in SQL Server Transact-SQL? If you e...
Where to find answers to frequently asked questions on Managing Security, Login and User in SQL Serv...
How To Change the Name of a Database User in SQL Server? If you want to change the name of an existi...
How To Connect the Oracle Server as SYSDBA in Oracle? This is Step 4. The best way to connect to the...