Showing next months data
I have a view showing me last months invoices
month('Date & Time') = month(today()) - 1 and year('Date & Time') = year(today())
and another for next month's
month('Date & Time') = month(today()) + 1 and year('Date & Time') = year(today())
But these fail in January and December.
I can't work out how to say "if month is 1 make the month to show 12" and "if month is 12 make the month to show 1" (for last month when its January and next when its December.)
Any tips!
3 replies
-
For the preceding month, something like:
let janu := month(today()) = 1;
month('Date & Time') = if janu then 12 else month(today()) - 1 end and year('Date & Time') = year(today()) - number(janu)
-
OK, thanks that helps a lot. Is there a resourse I can go to and understand the code Ninox is using. I am constantly looking in the 'manual'!
For example := What's that saying?!
Why can't we say
month('Date & Time') = if 1 then 12
or
if month('Date & Time') = 1 then 12
-
The use if a variable ("janu") is not strictly necessary. But since the result of comparing the current month with "1" is needed two times, it makes sense to compute it once and store it in a variable. You might as well write:
month('Date & Time') = if month(today()) = 1 then 12 else month(today()) - 1 end and year('Date & Time') = year(today()) - number(month(today()) = 1)
Content aside
- 3 yrs agoLast active
- 3Replies
- 186Views