How do I filter out / query all the commissions that's within the last month?

Options

I have a background task that's activated every 1st of the month to pay my affiliates a commission. How do I filter out / query all the commissions that's within the last month? Problem is that some months have 30 days, some months have 31 days, and so on...

Example:

On the 1st of October, I want to process all the commissions that came in from 1 Sept to 30 Sept.

On the 1st of November, I want to process all the commissions that came in from 1 Oct to 31 Oct.

And so on…

Tagged:

Answers