cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Optimize way to write services

Regular Member

Optimize way to write services

As the querypropertyhistory contains a lot of historical data, how can i efficiently get data for a particular time interval and write an optimized code operation.

2 REPLIES 2

Re: Optimize way to write services

// dateValue:DATETIME
var dateValue = new Date();

// dateAddDays(dateValue:DATETIME,amount:NUMBER):STRING
var calculatedDateValue = dateAddDays(dateValue, -1);

 
var endDate = new Date()
var params = {
	oldestFirst: undefined /* BOOLEAN */,
	maxItems: undefined /* NUMBER */,
	endDate: dateValue /* DATETIME */,
	query: undefined /* QUERY */,
	startDate: calculatedDateValue /* DATETIME */
};

// result: INFOTABLE dataShape: "undefined"
var result = me.QueryPropertyHistory(params);

Hi Sonali,

If you want to fetch 24 Hrs data you can use above code and if you want interval as Hrs , Minutes, Second you can take it from code snippets in TW.

Thanks & Regards
K Bairagi

Re: Optimize way to write services

Hi @SonaliPatro 

 

Just wondering if you're still trying to solve your issue. If you have found a solution, please post it for the benefit of others in the community or mark an existing response as the Accepted Solution.

 

Thanks,

Vibhuti