Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X
Hi ,
Looking to retrieve data from datatable using Timestamp field . I have requirement like retrieve current date data , weekly data (last 7 days) etc. here timestamp values can be duplicated . we want last 7 days entries from datatable. how we can do it?
Thank you
Solved! Go to Solution.
Hi Ciprian-Traian ,
I have done this requirement by using below code and it worked.
var days=7; // Days you want to subtract
var currentdate = new Date();
var lastDate = new Date(currentdate.getTime() - (days * 24 * 60 * 60 * 1000));
var day =lastDate.getDate();
var month=lastDate.getMonth()+1;
var year=lastDate.getFullYear();
logger.warn(lastDate);
//logger.warn(day);
var query =
{
"filters": {
"type": "Between",
"fieldName": "timestamp",
"from": lastDate,
"to": currentdate
}
};
Thank you
You can use example :
var query =
{
"filters": {
"type": "Between",
"fieldName": "timestamp",
"from": "2",
"to": "12"
}
};
More info can be consulted at Query Parameter for Query Services
thank you for quick response, but here we are not giving start and end date , I don't know how many entries there are in datatable , only entries I want that are inserted in last 7 days . you can use timestamp field.
Thanks
Maybe this :
var query =
{
"filters": {
"type": "GT",
"fieldName": "timestamp",
"value": "12"
}
};
Hi Ciprian-Traian ,
I have done this requirement by using below code and it worked.
var days=7; // Days you want to subtract
var currentdate = new Date();
var lastDate = new Date(currentdate.getTime() - (days * 24 * 60 * 60 * 1000));
var day =lastDate.getDate();
var month=lastDate.getMonth()+1;
var year=lastDate.getFullYear();
logger.warn(lastDate);
//logger.warn(day);
var query =
{
"filters": {
"type": "Between",
"fieldName": "timestamp",
"from": lastDate,
"to": currentdate
}
};
Thank you