@Coco_08 wrote:
@LinusH yes the current code will pick the values before 5years.the dates present are in timestamp
So if you have DATETIME values you need to use DT intervals with the INTNX() function to let it know it needs to do the adjustment in SECONDS and not in DAYS.
If you want to move by years then use the DTYEAR interval. So 5 years before now would be :
intnx('dtyear',datetime(),-5,'s')
You might want to express that as a datetime constant. That might allow for faster performance if indexes are involved. To do that use the %SYSFUNC() macro function to call the INTNX() and DATETIME() functions.
This will generate the datetime value as a number which should work fine in comparisons even if it looks funny to humans.
%sysfunc(intnx(dtyear,%sysfunc(datetime())),-5,s)))
... View more