microsoft-search / pnp-modern-search

Home of PnP Modern Search solutions, helping you move from classic to modern SharePoint and beyond
https://microsoft-search.github.io/pnp-modern-search
Other
388 stars 341 forks source link

Search Filters - date interval pick wrong dates #4030

Closed vofflan closed 3 weeks ago

vofflan commented 1 month ago

Version used 4.13.1.0

Describe the bug When adding a date interval to search filter I want to filter dates between for example From: August 8, 2024 and To: August 31 2024. When I do that the filter url looks like this: SitePages/Arkivsok.aspx?f=%5B%7B"filterName"%3A"RefinableDate00"%2C"values"%3A%5B%7B"name"%3A"2024-08-07T22%3A00%3A00.000Z"%2C"value"%3A"**2024-08-07T22%3A00%3A00.000Z"%2C"operator"%3A4%7D%2C%7B"name"%3A"2024-08-30T22%3A00%3A00.000Z"%2C"value"%3A"2024-08-30T22%3A00%3A00.000Z**"%2C"operator"%3A5%7D%5D%2C"operator"%3A"and"%7D%5D#

For some reason the wrong dates are picked.

To Reproduce Detailed steps to reproduce the behavior:

  1. Add a filter web part
  2. Add a date interval to filter web part
  3. Pick dates from date interval

Expected behavior If I pick date From: August 8, 2024 and date To: August 31, 2024 I want documents listed for thoose dates.

Screenshots filter_date_interval

Desktop (please complete the following information):

kasperbolarsen commented 1 month ago

Sounds like you encountered this , https://www.m365thinking.com/post/how-sharepoint-handles-datetime-stamps-and-why-it-causes-pnp-search-filter-urls-to-be-offset

vofflan commented 1 month ago

@kasperbolarsen; I've read your post and I understand why it says thoose dates in my url. But when I choose date August 31, 2024, I thought I also will get documents created on August 31 but thats not the case?! Its until 2024-08-31 00:00 then I guess or what?

kasperbolarsen commented 1 month ago

I think I understand the issue. If you enable "Show Selected Filters" it could be as this: image

yet the query sent to the API reads: RefinableDate07:range(2021-08-31T22:00:00.000Z,2024-10-07T22:00:00.000Z,from="GE",to="LE") Which does NOT include the start and end dates, yet the "Show selected filters" seems to indicate that those ARE included. Am I on the right track?

vofflan commented 1 month ago

For me it looks like this in url: [{"filterName":"RefinableDate00","values":[{"name":"2024-08-06T22:00:00.000Z","value":"2024-08-06T22:00:00.000Z","operator":4},{"name":"2024-08-30T22:00:00.000Z","value":"2024-08-30T22:00:00.000Z","operator":5}],"operator":"and"}] and show selected filter says: [Fastställd datum>="August 7, 2024" AND Fastställd datum<="August 31, 2024"]

So, I expected to get documents between August 7, 2024 and August 31, 2024. But the documents that are created on August 31, 2024 wont show upp within this search. I have to set "To"-date to Sept 1, 2024 and then documents created on August 31, 2024 will appear.

wobba commented 1 month ago

Oct 1-4 turns into this FQL: Write:range(2024-09-30T22:00:00.000Z,2024-10-03T22:00:00.000Z,from="GE",to="LE"), as the implementation is starting from and up until end date. I'm in Oslo, which means that is GMT+2, and the time portions are reduced with 2h to match my time zone as querying dates are in zero time.

If the end date should be including all values including that date is a semantic discussion.

OOB search would turn the same filter into: Write:(range(2024-09-30T22:00:00.000Z, 2024-10-04T21:59:59.999Z))"} where the default from is GE and default to is LT. If we are to align with OOB we add one more day to the to value as aligning with OOB search is always a good thing :)