user2643961
user2643961

Reputation: 23

Add three month to a date in sql

I have an SQL script where by I need to add three months to the existing date from the database, I have successfully done that however how do I convert the date into a date format: this is what I have done so far.

case
when be.Description = '3 Months from Purchase'
then DATEADD(Month, 3 ,ISNULL (REPLACE(CONVERT(CHAR(11),p.CarReleasedate, 113), '', '-'),'-')) 
else '-' 
end [Expiry date]

Any help would be appreciated

Upvotes: 0

Views: 6930

Answers (2)

Bobby
Bobby

Reputation: 2938

case
    when be.Description = '3 Months from Purchase' AND p.CarReleasedate IS NOT NULL
    then DATEADD(Month, 3, p.CarReleasedate)
    else NULL
end [Expiry date]

Upvotes: 1

hilley
hilley

Reputation: 21

If it's a datetime, you can just do this:

DATEADD(Month, 3, CarReleasedate)

That returns a datetime also.

Upvotes: 2

Related Questions