How to get the month name from a column?
I have a column txndate
Select Month(g.Txndate) as Month
This returns 1,2,3,4,.....12. How can I get Jan, Feb, Mar, etc?
How to get the month name from a column?
I have a column txndate
Select Month(g.Txndate) as Month
This returns 1,2,3,4,.....12. How can I get Jan, Feb, Mar, etc?
Try this...
SELECT CONVERT(CHAR(3), DATENAME(MONTH, GETDATE()))
Or this one (Thanks, Gordon Linoff)
SELECT LEFT(DATENAME(MONTH, GETDATE()), 3)
Customized for your table...
SELECT CONVERT(CHAR(3), DATENAME(MONTH, g.Txndate)) AS Month
SELECT LEFT(DATENAME(MONTH, g.Txndate), 3) AS Month
Result
+-------+
| Month |
+-------+
| Mar |
+-------+