
Hi all,
Date filtering is hurting my brain.
I'm trying to show only events with an event date within the last two weeks and include events happening today.
I tried this, but it's only including the events from the last 14 todays but not including today's events.
ShowColumns(Filter(Events,Event_x0020_Date>= DateAdd(Today(),-14),Event_x0020_Date<=Today()), "City", "Title")
Ideas? Thx!
Your problem is that your Date really includes a time as well. So, when you are saying Event_x0020_Date<=Today() here is how it really turns out (let's assume today's date):
5/10/2019 00:00 <= 5/10/2019 00:00
All seems like it should work...right?
Well, enter the real problem, you need to adjust for timezone. Chances are, your date for event date is really in the system as 5/10/2019 04:00 (or some other hour depending on your timezone). Well, that will never meet the criteria for <=.
So, you could try a couple of things:
1) Test this theory - change your formula to this:
ShowColumns(
Filter(Events,
Event_x0020_Date >= DateAdd(Today(),-14) &&
Event_x0020_Date <= DateAdd(Today(), 1439, Minutes)
),
"City", "Title"
)
This will add 24:59 minutes to Today's date...still today, but end of day.
2) Adjust for TimeZone. Change your Formula to this:
ShowColumns(
Filter(Events,
DateAdd(Event_x0020_Date, -TimeZoneOffset(Event_x0020_Date), Minutes) >= DateAdd(Today(),-14) &&
DateAdd(Event_x0020_Date, -TimeZoneOffset(Event_x0020_Date), Minutes) <=Today()
),
"City", "Title"
)
This will adjust the time zone of the dates to be correct. Then 00:00 should be 00:00
I hope this is helpful for you.