Been bubbling for a while and encountered a problem filtering dates that feels like it should have a much more elegant solution than the ones I’m using. Other posts I found felt too app-specific, so I’m hoping this can be a more general resource.
The issue stems from the way dates are always stored as both a calendar date and a specific time. In a personal habit tracker I’m making, finding all instances of a habit logged TODAY requires some pretty complex filtering because “created date = current date” is trying to match the time down to the millisecond, not just the calendar date.
Solution 1 was to just format the created date and current date/time as texts. That drops the time and matches the date as you’d write it on a check or document. Seems to work and can’t think of a situation that will create problems later.
But I did encounter a weird problem with my original solution, which was to extract the date from the created date and the current date/time and try to filter to find matches. January worked great, but once February rolled around, I was including old January things in the filter. It’s because the extract date sees January 2nd and February 2nd as the same — 2=2.
In hindsight it makes sense, but I imagine this issue might drive others crazy in the future, so I wanted to share my experience. Plus, I realized that I’d encounter a similar problem next year for my habits that track weekly and monthly. Once January 2023 rolls around, my January 2022 things will show up in the filter again because, of course, 1=1 when you extract the month.
Solution 2, then, was to just add another line to the filter that extracts and matches the year as well. I can’t imagine why that wouldn’t work long term, but it still strikes me as very complex just to filter for things that happened this week or this month. Easy to say, hard to code, I guess?
Other solutions I found in the forum involved lots of inequalities and rounding the date, but these seemed even more complicated. Maybe I’m missing something that’s obvious to professional coders, though? I tried to learn how to code many times over several years, but I failed every time. Only Bubble was able to put it within reach and make it all very logical to me. This date filtering issue seemed like a weird place where coding rules still trump common sense, though. Anyway, hopefully this helps someone who’s just getting started! Other thoughts and solutions welcome and appreciated.