Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X
Hi,
I am looking to retrieve data from datatable based on Current date but in Datatable stored format is Date and time.
if given input is Date only without time , i need to fetch matching records for the input date. how we can do it in TWX 9.1.
Thanks
1 day is 24(h)*3600(s)*1000(ms), maybe you can try
DateYouSelect < recordTime < DateYouSelect+24(h)*3600(s)*1000(ms)
OR recordTime/[24(h)*3600(s)*1000(ms)] = Dateyouselect/[24(h)*3600(s)*1000(ms)]
making mathmatic calculation to timestamp sometimes work
Hello @VaibhavShinde
You can use QueryDataTableEntries service of the data table by specifying query parameters, BETWEEN current date of "00:00:00" and "23:59:59:999".
Sample Code:
var d = new Date(); //Current Date
var fromdt = new Date(d.getFullYear(), d.getMonth(), d.getDate(), 0, 0, 0);
var todt = new Date(d.getFullYear(), d.getMonth(), d.getDate(), 23, 59, 59, 999);
var myquery =
{
"filters": {
"type": "BETWEEN",
"fieldName": "date",
"from": Date.parse(fromdt) ,
"to": Date.parse(todt)
}
};
// result: INFOTABLE dataShape: ""
var result = me.QueryDataTableEntries({
maxItems: 500 /* NUMBER */,
query: myquery /* QUERY */,
values: undefined /* INFOTABLE */,
source: undefined /* STRING */,
tags: undefined /* TAGS */
});