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

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

How to get the last logged entry prior to a given time

khayes1
15-Moonstone

How to get the last logged entry prior to a given time

Hi,

I have a service that takes an event time stamp as the input. In the service I want to get the logged value, for a particular property, at that time. The property is logged in a value stream

To do this I need to retrieve the last logged entry prior to the time  stamp I pass in as an input parameter. Currently I use QueryNamedPropertyHistory service using the input time stamp as the end date parameter for the query. This works for now while there aren't many entries in the log. The problem will come when the log has thousands of entries.

Unfortunately QueryNamedPropertyHistory ​only has an end date parameter. If there was a start date parameter I could use my time stamp as the startDate and some date further in the past as the endDate, so it would search backwards. It seems like there ought to be a simple way to get the last entry before a given time stamp.

Does anyone have any ideas?

Thanks in advance.

ACCEPTED SOLUTION

Accepted Solutions
ankigupta
12-Amethyst
(To:khayes1)

HI Kieron Hayes​,

QueryNamedPropertyHistory has both StartDate and EndDate Parameter as input.

I think you can set the MaxItems as 1 and oldestFirst as false and endDate to get the last entry before a given time stamp.

View solution in original post

2 REPLIES 2
ankigupta
12-Amethyst
(To:khayes1)

HI Kieron Hayes​,

QueryNamedPropertyHistory has both StartDate and EndDate Parameter as input.

I think you can set the MaxItems as 1 and oldestFirst as false and endDate to get the last entry before a given time stamp.

khayes1
15-Moonstone
(To:ankigupta)

Hi Ankit,

thanks for your reply. You are correct, there are both start and end input parameters. Not sure why I thought there was only an end date .

Kieron

Announcements


Top Tags