Hello,
I am trying to filter my dataset so that it only returns the last 12 months but includes all the data from the 1st of the month 12 months ago.
Right now I'm using the following formula:
[OpenDate] >= DateTimeAdd(DateTimeToday(),-12,"months")
So for instance if today is 24th November 2022 the earliest data it shows me is from 24th November 2021. However I would like to adjust this so that it looks at the month we're in today and returns the last 12 months from day one of that month. So for this example the data returned would start from 1st November 2021.
Not sure if this is achievable... any help is much appreciated!
Solved! Go to Solution.
Hi @Crispy131
Two ways to adapt your formula to do this:
[OpenDate] >= DateTimeFormat(DateTimeAdd(DateTimeToday(),-12,"months"), '%Y-%m-01')
[OpenDate] >= DateTimeTrim(DateTimeAdd(DateTimeToday(),-12,"months"), 'firstofmonth')
Hey @Crispy131, you can use the DateTimeFirstOfMonth() function to return the first day of the current month and then implement the same kind of filter expression. The following works - example here where I generated all dates since 1st Jan 2020:
[Date] >= ToDate(DateTimeAdd(DateTimeFirstOfMonth(),-12,"months"))
Brilliant! Thank you