Skip to main content
1-Visitor
June 6, 2017
Solved

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

  • June 6, 2017
  • 1 reply
  • 2042 views

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.

Best answer by ankigupta

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.

1 reply

ankigupta5-Regular MemberAnswer
5-Regular Member
June 6, 2017

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.

khayes11-VisitorAuthor
1-Visitor
June 8, 2017

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