Pages

Thursday, November 7, 2013

Get Day,month,year from Date using datepart( ) Function in SQL Server


Use this function to get the Year of current Date:
datepart(yy,date)

Use this function to get the month of current Date:
datepart(mm,date)

Use this function to get the day of current Date:
datepart(dd,date)


Ex:

Select Datepart(dd,admissiondate) from Student;

This print the day of the date in the  'admissiondate' column

No comments:

Post a Comment