Business scenario is to select the list items which are satisfying the following criteria:
StartDate >= Today <= EndDate
The simple working code using PNP JS is as below:
let web = new Web(this.props.adminSiteURL);
let alerts: Alerts[] = await web.lists.getByTitle('Alerts').items
.filter(`StartDate le ` + new Date().toISOString() + `or StartDate eq ` + new Date().toISOString()
+ `OData__EndDate ge ` + new Date().toISOString() + `or OData__EndDate eq ` + new Date().toISOString()).get();
return alerts;
let alerts: Alerts[] = await web.lists.getByTitle('Alerts').items
.filter(`StartDate le ` + new Date().toISOString() + `or StartDate eq ` + new Date().toISOString()
+ `OData__EndDate ge ` + new Date().toISOString() + `or OData__EndDate eq ` + new Date().toISOString()).get();
return alerts;
No comments:
Post a Comment