Link to home
Start Free TrialLog in
Avatar of SriChary
SriChary

asked on

Update Year of Datefield column with 2008 in MS SQL

Hi,

I have this Date Field in my table in DATETIME datatype and I would like to update the year with 2008 of the entire table.
I tried this but it did not work
Update Productivity
 set RecCreateDate="2008"
where RecCreateDate is not null

It gave an Error.
Could you please give me a correct SQL statement for this
Avatar of tbsgadi
tbsgadi
Flag of Israel image

Hi,
DATETIME datatype holds a whole date like 1/1/2008 not just the year.

Gary
Avatar of SriChary
SriChary

ASKER

Hi tbsgadi,

Yes DateTime datatype holds a whole date and I want to update just the year in it.

For eg: If I have a date "01/15/2003"
I want to update it to "01/15/2008"

Any options please.

Thanks
SOLUTION
Avatar of TimSledge
TimSledge
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial