2

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

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Karamzov
  • 343
  • 1
  • 4
  • 12

1 Answers1

2

Use the DATEADD function:

SET @Deactivate = DATEADD(YEAR, 1, @Activate)
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459