Skip to main content
16-Pearl
August 13, 2024
Question

fetch entries created in last 30 days from Datatable

  • August 13, 2024
  • 1 reply
  • 1224 views

Dear Community,

    So below in attachment is my datashape of my datatable and currently i am getting all the entries in one of my service. Is there anyway that with infotable capabilities i can get entries which are created in the last 30 days. As you can see i have one of the parameter qualityCheckTimestamp which records the datetime for the entry. 

Now i would like to use pre existing function of infotable to get the entries created in last 30 days and if its not possible then i would have to iterate through all the entries to get the desired entries which would might be slow process. 

so anyone have a clue about it?

 

Thank you 🙂

 

 

Jamal8548_0-1723545679759.png

 

1 reply

MA873117416-PearlAuthor
16-Pearl
August 13, 2024

I think i have a solution to my post. Please ignore other comments  as they have highlighted my previous error in this post and now i have edited the reply and this is solution

 

const currentDate = new Date();
const fromDate = new Date(currentDate.getFullYear(), currentDate.getMonth() - 1, currentDate.getDate());
 
 var query = {

 "filters": {
 "fieldName": "qualityCheckTimestamp",
 "type": "BETWEEN",
 "from": fromDate, 
 "to": Date.now() 

 } 
 };

 

request payload:

Jamal8548_0-1723547469735.png

 

19-Tanzanite
August 13, 2024

Hi @MA8731174 

 

Try below script 

let fromDate = dateAddDays(new Date(), -30);
let result = fromDate;

 

Also consider client and server timezone difference

 

/VR