rhonda
November 2, 2023, 9:18pm
1
I am trying to filter items from a list using multiple values including a Date/Time field. I cannot find any documentation on the pnp site regarding using dates as a filter. Can someone help?
Hello @rhonda ,
Please find the example on how to filter retrieved items by date in this post:
opened 10:35PM - 07 Jun 19 UTC
closed 11:19PM - 07 Jun 19 UTC
auto-locked
### Category
- [ ] Enhancement
- [ ] Bug
- [ X] Question
- [ ] Documentation… gap/issue
We have a requirement to list all the SharePoint calendar list item that "EventDate" date field is **larger** then **30** days before today and **less** than **60** days after today.
I've constructed the two dates already.
let pastDate = new Date(new Date().setDate(new Date().getDate() - 30));
let futureDate = new Date(new Date().setDate(new Date().getDate() + 60));
Can someone help to provide the filter below that for the query?
sp.web.lists.getByTitle("PubsMeeting").items.filter(**??????**).top(100).orderBy('EventDate').get()
It seems to be easy in REST calls as people used here.
http://neganov.blogspot.com/2013/06/filtering-items-by-date-range-using.html
However, it's seems to be difficult in the PnP js.
Your help is highly appreciated!!!