Date Round to Month

All

This is probably easy but I have a an expression of “date: rounded down to month: extract month”, that works in nearly all cases except for Jan 31, 2022, 7:00pm, which returns 2 instead of 1. I have the extract month set to users current time zone. Not sure what the problem is. Can anyone provide a hint of where to start.

image

Thanks in advance.

Of course a quick band-aid is having the next step conditionally ensure edge cases you find are set to the appropriate value.

Have you found any other values with this behavior? I would check other months with the same values, and if it’s a front end workflow, use the debug mode step-by-step to see which part of the expression is going wrong.

-Kevin
Learn Bubble and Canvas with us for free at airdev.co/bootcamp!

Hi @mlw18064,

Can you provide a bit more context? Why is the month being rounded and extracted? Just trying to understand the bigger picture and get a sense for what you’re wanting to accomplish.

I have a list of transactions that are dated, and I group these into monthly buckets. I assign a variable with this number and sort, search accordingly.

Thanks

1 Like

That’s very odd. I get the expected result for that datetime. I wonder if it has something to do with the timezone of the source data.

I guess I’m unclear as to why the date is being rounded to month before the month is extracted. It seems to me the same month value should be returned whether rounded or not.

As I understand it, :rounded down to month just results in a date equal to the first of the month at 12:00am - that is, the very start of the month - which would be handy for getting the start of a date range if querying by month.

I am now having trouble recreating the issue. I have data that is clearly wrong in my database, but I can’t seem to recreate it with the same expression. I am going to correct the data, and delete the round down expression and just extract month as you suggest and let her run. Thanks Sudsy.