Click here to Skip to main content
15,903,854 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Expert,


How do you get the MONTH & YEAR of the current date (i.e GETDATE() )

SQL
@CMONTH = MONTH (GETDATE())
@CYEAR = MONTH (GETDATE()) 

Thanks
Posted
Updated 29-Nov-14 0:52am
v2
Comments
Zoltán Zörgő 30-Nov-14 7:57am    
Any progress? If you have found my answer of use, feel free to accept it!

you are looking for DATEPART[^]

SQL
declare @m int = datepart(MONTH, GETDATE())
select @m
 
Share this answer
 
v2
try this :
SQL
declare @cmonth int,@cYear int ;
select @cmonth=MONTH(getdate());
select @cYear=Year(getdate());

select @cmonth;
Select @cYear;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900