Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting DateTime to nvarchar, just month and year

How to convert the datetime value to nvarchar and want to format it "Month, Year" e-g October 1st 2009 value should get converted to "October, 2009"

like image 624
Khurram Aziz Avatar asked Oct 24 '25 02:10

Khurram Aziz


1 Answers

use this:

select CONVERT(nvarchar(50),   DATENAME(m, getdate()) 
                               + ', ' 
                               + DATENAME(yyyy, getdate())
              )

OUTPUT:

--------------------------------------------------
October, 2009

(1 row(s) affected)
like image 162
KM. Avatar answered Oct 26 '25 16:10

KM.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!