In this case I think you can just use
dateColumn >=dateadd(month, - 12, @apl )
where @apl is the date selected from Date Picker.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have a query that works except for one thing i want it to show me data for the past 12 months based on a date a user selects in a ssrs report.`
`Declare @apl as Date = '1/1/2022' ;
Declare @prop as int = 8000 ;
--*/
SELECT
tblPropsFreeRent.intProp,
tblPropsFreeRent.dtMonth,
DATENAME(m, tblPropsFreeRent.dtMonth) + ' ' + DATENAME(yyyy, tblPropsFreeRent.dtMonth) AS strDate,
intNumTimes AS intNumTimes,
tblPropsFreeRent.mnyAmount AS curAmount,
intMoveIns AS intMoveIns,
W.fltOcc AS fltOcc
FROM tblPropsFreeRent
LEFT JOIN SovranMisc.dbo.tblPropsLateFeeWaive W ON tblPropsFreeRent.intProp = W.intProp AND tblPropsFreeRent.dtMonth = W.dtMonth
WHERE
---tblPropsFreeRent.dtMonth = @Date
DATEDIFF(Month,tblPropsFreeRent.dtMonth,GETDATE()) <=13
--tblPropsFreeRent.dtMonth >= DateADD(mm,DATEDIFF(mm,0,@Date)-12,0)
and tblPropsFreeRent.intProp IN(@Prop);
(putyourdatecolumnhereOrBuildaDate)>= DATEadd(Month,-12,GETDATE())
tblPropsFreeRent.dtMonth>= DATEADD(Month,-12,CAST(GETDATE() as date))