Since Dremio is proprietary, and we don't run it where I work, I can't test specific code for you, but I can explain the approach. I'll leave working out the exact syntax to you.
Broadly speaking, the solution is to use the date value that you have to calculate the first day of the next month, then subtract one day. This works because every month has a first of the month, and every SQL engine will get the correct EOM date when subtracting one from the first. In most systems, there are several ways to do that.
The sort of "brute force" way is to take your current date, current_datefield
, then EXTRACT
the year and the month. Add one to the month. Use those values and a hardcoded 01
to "build" the first of next month. There will probably be a TO_DATE
or some such involved there.
Now just wrap that value in a DATE_ADD
function to subtract one.