Geo SCADA: How to use timestampadd in an SQL query
In the first example below a note was added to a point at 4:14:04pm local time. Two queries are shown: one which displays the note with it's original timestamp and the second which displays the note with an offset of -2 hours.
The point (that the note is associated with) has an object ID of 20283. The original query returns the time and text of the note using the following code:
SELECT
NOTETIME, NOTETEXT
FROM
CDBOBJECT
WHERE
ID = 20283
This query results in the original time of 16:14:04.116 being displayed in the embedded list.
The modified query returns the time and text of the note with a -2 hour offset using the following code:
SELECT
{ FN TIMESTAMPADD( SQL_TSI_HOUR, -2, NOTETIME ) } AS NOTE_OFFSET, NOTETEXT
FROM
CDBOBJECT
WHERE
ID = 20283
Here the timestampadd clause is used to display the notetime two hours earlier at 14:14:04.116
In the second example below the timestampadd clause is used to display the timestamp of a historic value with a two hour offset.
The original historic value was logged to the Geo SCADA historian at 4:16:21.055. The first query using the following code to display the data as it is:
SELECT
RECORDTIME, VALUE
FROM
CDBHISTORIC
WHERE
ID = 20283
The result is a list with the original timestamp of 4:16:21.055 and the value.
The modified query returns the timestamp and value with a -2 hour offset using the following code:
SELECT
{ FN TIMESTAMPADD( SQL_TSI_HOUR, -2, RECORDTIME ) } AS TIME_OFFSET, VALUE
FROM
CDBHISTORIC
WHERE
ID = 20283
The result is a timestamp that displays as 2:16:21.055.
Publicado para: Schneider Electric Mexico




¿Necesitas ayuda?
Selector de productos
Encuentra rápida y fácilmente los productos y accesorios adecuados para tus aplicaciones.
Pedir presupuesto
Comienza tu consulta de ventas en línea y un experto se pondrá en contacto contigo.
¿Dónde comprar?
Encuentra fácilmente el distribuidor de Schneider Electric más cercano a ti.
Centro de ayuda
Encuentra recursos de soporte para todas tus necesidades en un solo lugar.