How to get month in 3 letters in SQL.
In SQL Table data is inserted:
2016-01-07 09:38:58.310
I need only month result in 3 letters like below:
Jan
SQL SERVER: In SQL SERVER, we can use a combination of functions 'DATENAME' and 'DATEADD' functions to get a month name from a month number.
MySQL MONTHNAME() Function The MONTHNAME() function returns the name of the month for a given date.
Assuming you're using SQL Server 2012 or newer, you can use the FORMAT
function:
SELECT FORMAT([Date], 'MMM', 'en-US')
Adapt the locale as needed.
Since you're on SQL Server 2008, I'd use
SELECT LEFT(DATENAME(MONTH, [Date]), 3)
Try this (I am assuming you are using Sql Server).
Select Convert(char(3), GetDate(), 0)
If you need full name of month, try
Select Datename(month, GetDate())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With