How to retrieve Year / Month from Current or Any Datetime in SQL Server

Session 2 :


How to retrieve Year / Month from Current or Any Datetime ?


select 
[YEAR] = YEAR(getdate())
,[YEAR] = DATEPART(YY,getdate()) 
,[MONTH] = month(getdate())
,[MONTH] = DATEPART(mm,getdate())
,[MONTH NAME] = DATENAME(mm, getdate())


Output : -


YEAR YEAR MONTH    MONTH MONTH NAME
2013 2013 3            3                 March



Comments

Popular posts from this blog

Add Serial no in crystal report without coding

File operations in C# (.net)

SQL – Generate decimal numbers sequence for particular number range