Back

Topic

[KB590]How to convert a time into the FILETIME format used by the HDS

Tags: HDS, Scada Basic, Scripting

12 years ago
By RM
Options
Print
Applies to:

PcVue version 11 onwards.


Summary:

How to convert, using SCADA Basic, a Unix time (also known as Epoch time, Posix time…) to the FILETIME format as used by the HDS.
The program developed and tested using PcVue version 11. Since version 11, PcVue Scada Basic language is managing a new type of variable named Longlong, which is handeling intergers from -9,223,372,036,854,775,807 to 9,223,372,036,854,775,807. This allows to generate Chrono values.


Details:

The HDS Chrono field is in FILETIME format which is the number of 100 nanosecond intervals since January 1, 1601 (UTC).
With SCADA Basic you have the function DATETIMEVALUE() which returns a number representing the number of milliseconds since January 1, 1970 (UTC).

Not the same units and not the same start date but, by using a multiplier and adding an offset, you can convert a time to FILETIME format.
ChronoValue = TOLL(DATETIMEVALUE())*10000 + 116444736000000000;

Download attachments: FILETIME.svb.txt


Created on: 29 Aug 2012 Last update: 13 May 2024