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
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())
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)
Or you could just do:
LEFT(GETDATE(), 3)
For instance you could declare a variable:
Declare @MONTH VARCHAR(3)
Set @MONTH = LEFT(GETDATE(), 3)