Suppose that we have an agent named Last Month.. Its $StartDate is the start of last month, and its $EndDate is the end of last month. For now, we’ll just suppose those are set by magic — or that you type them yourself.
Now, what is the agent’s query? I think it would be:
$Created>$StartDate(agent) & $Created<$EndDate(agent)
I haven’t tested this, but really it’s restating your problem. OK so far?
Now, how would we set the start date? I’m going to use a Rule on the agent. That’s overkill — an edict would be fine — but it’s simpler to test.
First, a slightly easier problem. How would we find all the notes in the last 30 days?
$StartDate=date("today-30 days");
$EndDate=date("today");
Now, that’s not what you asked, but it’s just a little easier. OK so far?
Now, how would we construct “the first day of last month”? Let’s start by figuring out what this month is:
$MyDate=date("today");
$MyNumber=$MyDate.month();
So, last month is one less. Of course, there’s the problem of January!
var:number year=$MyDate.year();
var:number month=$MyDate.month()-1;
if (month<=0) {
month=12;
year = year-1;
}
$StartDate=date(year,month,1);
$EndDate=date($MyDate.year(),$MyDate.month(),1);
Again, untested, but you should get the idea.