Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
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
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:
Hi @MA8731174
Try below script
let fromDate = dateAddDays(new Date(), -30);
let result = fromDate;
Also consider client and server timezone difference
/VR
Your piece of code is a JS service executed on the server, not on the client. The request payload you show is a request sent by your browser.
Please explain how these two come together.
also, when running the code, you can easily log.warn into scriptlog and check there if your date computation is correct, e.g. log.warn("fromDate="+fromDate);
Thanks for highlighting it actually first i have created two input parameters of the service and was looking into them from network tab but now i dont need them and i can give directly min and max date which i have done now and yes i would use log.warn level logger to see. That was the confusing part for me and my code above is all fine getting right dates which i have stated above.
Hello @MA8731174,
It looks like you have some responses from some community members. If any of these replies helped you solve your question please mark the appropriate reply as the Accepted Solution.
Of course, if you have more to share on your issue, please let the Community know so other community members can continue to help you.
Thanks,
Vivek N.
Community Moderation Team.