Link to home
Start Free TrialLog in
Avatar of Stefan Motz
Stefan MotzFlag for United States of America

asked on

How to replace the year in a date in SQL Server

Hi Experts,
I would like to replace the year part in a date in SQL Server.
I've tried the following, but I get this error message:
Msg 242, Level 16, State 3, Line 1
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.

UPDATE VacationBid
   SET Day1 = REPLACE(Day1,'2014','1015')
 WHERE Day1 LIKE '%2014%'

Open in new window


Thank you for your help
SOLUTION
Avatar of Jim Horn
Jim Horn
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
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
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
Avatar of Stefan Motz

ASKER

Very funny!
My users didn't want to travel back in time just to take vacation in year 1015.
Sorry, it was just a typo.
We aim to please.

Every once in awhile we get a question about Access 200, and it takes awhile to explain that the Romans' first couple of desktop database applications left a lot to be desired, and that 202 was really the first usable application.
JH

I liked the old school overalls pic .. why so formal now ?
When you blow two grand on family photos there's a strong desire to justify spending the money.

The previous photo was after a Tough Mudder I ran a couple of years ago.
If you think it's a better photo for EE then I'll put it back.  
You're the first one that's commented on it.
I hear that
that's why all family photos are taken with our cells :)

coming from the guy DJ'ing in his picture so what do I know :)