Jump to content

Timestamp for last sample in a signal


Ruben
 Share

Recommended Posts

Hi - I am wanting to get a time value for the last sample in a signal. What is the formula for this?

I am using it to create a 24hr average from the last value in a signal, and have this updating as the signal is updated. the now() function takes the current time, not the last sample time.

Any advice? Thanks

Link to comment
Share on other sites

Hi Ruben, 

you can do it by using this formula. The formula gets the values for the last eight hours, picks the last sample and gets its key (timestamp). Based on that timestamp the condition of the previous 24 hours is build.

image.png.220596862e149f8bac6641bcca52d3e8.png

You can also use pick(-1) instead of last(). You should keep in mind that the capsule itself is uncertain because of the use of now().

Regards,

Thorsten

 

Link to comment
Share on other sites

  • 1 year later...
  • Seeq Team

Post below documents how you could pull the last sample's timestamp into a Scorecard - in case all you wanted was to just view that timestamp.

Enter the following into a new Formula:

//In this formula, we will create a signal of all the timestamps for each sample point coming into Seeq

//Create a condition with tiny capsules for each sample point
// NOTE - to the get the accurate timezone date/time, I need to delay my signal according to my UTC-6h adjustment for Mountain timezone
//        if you are in Central for instance, you would do UTC-5h, or .delay(-5h)
$sampleCapsules = $signal.delay(-6h).toCapsules()

//Find the timestamp of each recorded sample point
// NOTE - you may need to change the 1d to a larger value, as this is the interpolation length
//        so if your samples are spaced by more than 1d, increase to 2d and see if this interpolates
$sampleCapsules.toSignal('End').toLinear(1d).toString()

//Below transform is Optional to view the timestamp in a neater format of MM/DD/YYYY HH:MM
  .replace('/(?<year>....)-(?<month>..)-(?<day>..)T(?<hour>..):(?<minute>..):(?<sec>..)(?<dec>.*)Z/' , 
           '${month}/${day}/${year} ${hour}:${minute}')

Then, in a new Scorecard Metric, grab the Value at End. Every time you return to Seeq, you can "step to now" and get the latest timestamp for the last sample, corrected for your timezone per the delay above. 

image.png

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...