Extracting Year,Month and Day from Datetime Object

vishalneeraj-24503
Posted by vishalneeraj-24503 under Sql Server category on | Points: 40 | Views : 232
Year Part:
select datepart(yyyy,getdate()) 'year part';
select year(getdate()) 'year part';

Output:
2014


Day Part:
select day(getdate()) 'day part';
select datepart(dd,getdate()) 'day part';

Output:
28


Month Part:
select month(getdate()) 'month part';
select datepart(MM,getdate()) 'month part';

Output:
06

Comments or Responses

Login to post response