Returning the duration (in minutes) of an active alarm.


How can I return the duration (in minutes) that the alarm was active?



Alarm sources are Elipse E3‘s objects which set up all the information regarding to alarm conditions. Each alarm source allows you to configure its limits, event-related message, and severity, as well as whether the event needs acknowledgement.

There are five types of alarm in Elipse E3; they are: analog, digital, dead band, rate of change, and discrete. For further information on these alarms, their configurations, and how to use them with the Elipse system, check out our article E3: Alarm Types.

In order to return the duration that the alarm was active, you can use SQL’s DateDiff method. This method returns the count (as a signed integer value) of the specified datepart boundaries crossed between the specified startdate and enddate; that is to say, it will return the difference between the moment the alarm became inactive and the moment it became active.

DateDiff function’s syntax is as follows:

DATEDIFF ( datepart , startdate , enddate )

Its arguments are:

  • datepart: The units in which the function reports the difference between the startdate and enddate. Commonly used datepart units include month or second. Its value can’t be specified in a variable, nor as a quoted string (like “month”).
  • startdate: an expression that resolves the initial timestamp.
  • enddate: an expression that resolves the final timestamp.

For example, the query below illustrates how to return the difference between timestamps in minutes:

SELECT InTime, OutTime, DateDiff("n", InTime, OutTime) AS ActiveTime
FROM Alarms
WHERE (InTime>0 AND OutTime>0)
ORDER BY InTime Desc

For further information on DateDiff function, you can check out Microsoft’s official documentation on the subject.

Este artigo foi útil? Was this post helpful?

Leave a Reply

Your email address will not be published.Required fields are marked *