Karamzov
Karamzov

Reputation: 403

set date from one year of getdate ()?

I got a DECLARE statement like this

DECLARE ,@ACTIVATE DATETIME,
        @DEACTIVATE DATETIME

I want to set the Activate date as today's date, which is

SET @ACTIVATE = GETDATE()

I want to set the @DEACTIVATE date to one year from the Activate date.

 ACTIVATE = 30/07/2018
 DEACTIVATE = 30/07/2019

I can set DEACTIVATE date using string, but is there any other function or method to do this?

Regards

Upvotes: 2

Views: 139

Answers (1)

marc_s
marc_s

Reputation: 754688

Use the DATEADD function:

SET @Deactivate = DATEADD(YEAR, 1, @Activate)

Upvotes: 2

Related Questions