I am using PnPjs to query a SharePoint list. I am using this code:

let today: string = (new Date()).toISOString(); 
today = `${today.substring(0, today.indexOf('T'))}T00:00:00Z`
let results = await sp.web.lists.getByTitle('my list').items
.filter(`datetime'${today}' ge myStartDate and datetime'${today}' le myEndDate`).get()

However, this is not filtering the right data as for example, today's date has the T00:00:00Z and it excludes the start date when in the same day as it has a value more than T:00:00:Z.. how do we compare date/no time?

1 Answer 1


In SharePoint, date field uses ISO8601 DateTime format. We cannot just filter the date only.

As a workaround, you could use T23:59:59Z in today's date for start date and T00:00:00Z for end date

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.