Hi,
I appreciate any help with this!
I have this query that takes past 6 month, I want to make this dynamic because I'm using this in Powerbi and so each month I refresh the data in powerbi, it bring in the current past 6 month.
SELECT DISTINCT AGENT_ID
FROM DB2PROD.BONUS_PAYMENT
WHERE BONUS_TYPE = 'R'
AND NEW_BIZ_YR = '2022'
AND NEW_BIZ_MO >= '3'
CURDATE() Returns the current date.
MONTH(date_exp) Returns the month based on the month field in date_exp as an integer value in the range of 1 – 12.
YEAR(date_exp)
Returns the year based on the year field in date_exp as an integer value. The range is data source – dependent.
TIMESTAMPDIFF(interval, timestamp_exp1, timestamp_exp2)
So using a combination of these functions you could figure it out. Might be better off posting on a winsql forum?