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

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

What is the quickest way to find the earliest timestamp in the value stream?

Michail
10-Marble

What is the quickest way to find the earliest timestamp in the value stream?

Hi there,

I'd like to know what is the best way to find the earliest (first) timestamp in the value stream. Code below does work, but it takes a long time if there are few propertyNames. It necessary to know at what point data became available. I'd be grateful for your advise, thanks!

var endDate = new Date();

var startDate = new Date();

startDate.setYear(2000);

       

    var params = {

        oldestFirst: true /* BOOLEAN */,

        maxItems: maxitems /* NUMBER */,

        endDate: endDate /* DATETIME */,

        propertyNames: propertyNames /* INFOTABLE */,

        query: undefined /* QUERY */,

        startDate: startDate /* DATETIME */

    };

    // result: INFOTABLE dataShape: "undefined"

    var myQuery = Things[thing].QueryNamedPropertyHistory(params);

    var result = myQuery.rows[0].timestamp;     //DATETIME

1 REPLY 1
jlittle
12-Amethyst
(To:Michail)

It may be faster to simply limit your query to a single returned item.   You're passing in "Oldest first", which means the first row that you're getting is already the oldest row.  Everything beyond that would be unnecessary data to transfer from the database and could slow things down.

Start by setting maxItems to 1 and see if that returns faster and gives you what you need.

Announcements


Top Tags