Applies to:
PcVue all versions. |
||||||
|
||||||
Summary:
This article discusses discrepancies in the ways date-time formatting works in PcVue, SCADA Basic, VBA and animations. |
||||||
|
||||||
Details:
Calculations of date and time do not always take into account time zone bias and summer/winter bias, depending on the way you retrieve those values:
Scada Basic When you use SCADA Basic date-time management functions, the reference day for all of them is the 1st of January 1970. However most of those functions (not only in PcVue) can be used only for date-times after the 1st of January 1980. For that reason, DATETIMEVALUE(“01/01/1970″,”00:00:00”) returns 0 and DATETIMESTRING(DATETIMEVALUE(“01/01/1970″,”00:00:00”)) is unable to return an useful string. These differ as follows This explains why you get differences of one or more hours when using date-times from PcVue and/or the from DATETIMESTRING function, from those obtained with the DATETIMEVALUE function. The discrepancy depends on the local time zone and whether the operating system has switched to or from seasonal time.
VBA Many functions are available in VBA to retrieve date and time (date, datevalue, datetime module). For instance: Animations Suppose your PC is set to GMT+1 (i.e. with summer time adjustment). A shift when you display in DATETIMESTRING format the content of a register variable @NOW coming from the VBA Datetime.Now function. The animation format Date and Time always displays a UTC Time. Solution In SCADA Basic:
Example Suppose that your PC is set to UTC+1 (for the summer time adjustment), and the register variable @NOW is configured as follows: In VBA you could update @NOW as follows: Private Sub Text1_Click() [@NOW] = DateTime.Time & ” ” & DateTime.Date End Sub In SCADA Basic you could update it as follows: Sub Main() @NOW = Datetimestring( Datetimevalue() , “#h:#m:#s #D/#M/###Y”); End Sub
This mimic shows the results from PcVue, VBA and SCADA Basic, within a few seconds of clicking the buttons to run each script: The times given by PcVue, SCADA Basic and the VBA script reflect the time zone bias (UMT+0) and British Summer Time (i.e. +1 hour), but the value displayed with date and time format does not. Further information The date and time handling functions are described and illustrated in the Help for PcVue: |
||||||
|
||||||
|
Created on: 05 Nov 2010 Last update: 13 May 2024