TSQL, How can I get only the year part?

I have a column type as nvarchar(4) null which I converted to DateTime.  It originally has the 4 digits of year.  After changing to DateTime type, the data now has a 1/1 as the month and date and 12;00 am as the time.  How can I change it to only the year part?  thanks.

This is what I used to change the column type
ALTER TABLE BkPersonDegree ALTER COLUMN degree_Date DateTime
lapuccaAsked:
Who is Participating?
 
Ephraim WangoyaConnect With a Mentor Commented:


select DATEPART(YEAR, CONVERT(DATETIME, COLUMN, 101))
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
datetime is simply not only year, so if you only want the year, why change to datetime?
please clarify
0
 
lapuccaAuthor Commented:
Ang, I thought it would be easier to use for comparing in sql  but I think you're right.  That shouldn't make any difference when I query for certain year for cmoparring this column data in a query?
0
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
indeed. if all you need for the column is the year, then use INT datatype actually and not even varchar.
with INT, you can even do maths without having to cast the data type.
0
 
lapuccaAuthor Commented:
Thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.