Reading Tag Data with Local timestamp
Returning tag data recorded by Litmus Production Record Database through the use of these SELECT statements can be used for example by any visualization platform which allows to integrate with MSSQL like;
- Grafana
- PowerBI
- Tableau
Further can these queries be used by any other application which allows for an ODBC connection such as:
- Excel
- C#
- .Net
- Python
- R
They can also be part of a larger stored procedure developed by users with T-SQL.
Run SELECT query with Function PROREC_Tag_GetTagDataLocalTime as FROM clause.
Variable name | Datatype | Description | Example |
---|---|---|---|
@Tag | VARCHAR(50) | The Tag name. If no specific Tag name is to be queried or to get a list of Tag name's, the value can also be DEFAULT which will assume the value %. | Pressure DEFAULT |
@Device | VARCHAR(50) | The device name for the tag. If no specific device is to be queried or to get a list of devices, the value can also be DEFAULT which will assume the value %. | Asset1 DEFAULT |
@Item | VARCHAR(50) | The item of the tag which the value represents. If no specific item is to be queried or to get a list of item's, the value can also be DEFAULT which will assume the value %. | Value DEFAULT |
@TagValue | VARCHAR(256) | A specific value for the Item of the Tag. If no specific Value for the Item is to be queried or to return all Values, the value can also be DEFAULT which will assume the value %. | 20 DEFAULT |
@Quality | VARCHAR(4) | A specific quality of the tag value. (GOOD or BAD) If no specific quality for the value is to be queried or to return all qualities, the value can also be DEFAULT which will assume the value %. | GOOD DEFAULT |
@StartTime | DATETIME | The start of the time period for which to query data. The time will be treated as in local time and will be adjusted to UTC using the @Timezone value. If no specific start time is required, the value can also be DEFAULT which will assume the value null. This will trigger the function to calculate a start time of -1h from the current time stamp. This means the default time period for which data are returned is always the last hour. | 2023-03-09 12:57:59.200 DEFAULT |
@EndTime | DATETIME | The end of the time period for which to query data. The time will be treated as in local time and will be adjusted to UTC using the @Timezone value. If no specific end time is required, the value can also be DEFAULT which will assume the value null. This will trigger the function to use the current time stamp. This means the default time period for which data are returned is always the last hour. | 2023-03-10 12:57:59.200 DEFAULT |
@Timezone | INTEGER | The Number of hours your local time zone is ahead or behind the GMT time zone. If the user does not know this value, it can be left as DEFAULT which will assume the value 0 or GMT. The value can be positive (example: 8 for UTC +8) or negative (example: -6 for UTC -6) | 2 DEFAULT |
To query tag data, execute a SELECT statement from the function PROREC_Tag_GetTagDataLocalTime providing all the required inputs. Below is an example using T-SQL in SQL Server Management Studio:
The function returns a table as result.
It is possible to reduce the number of columns returned by the SELECT statement. Below is an example using T-SQL in SQL Server Management Studio:
This will reduce the number of columns returned to only the two selected.
It is possible to sort data based on users requirements returned by the SELECT statement. Below is an example using T-SQL in SQL Server Management Studio:
The result will be a table, where all rows are sorted by their Recordtime in ascending order.