Reputation: 23
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
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
Reputation: 21
If it's a datetime, you can just do this:
DATEADD(Month, 3, CarReleasedate)
That returns a datetime also.
Upvotes: 2