Relative Time Syntax

PARCview’s syntax for the relative time field follows the OPC HDA 1.20 Specification, except that the relative times are calculated based on the local machine’s system time.

From the OPC HDA 1.20 Specification, copyright OPC Foundation, all rights reserved:

OPC Historical Data Access

Specification

(Version 1.20)

 

The time is considered to be a relative time local to the server. This means that all times are given in UTC time, compute from the current time on the server's local clock. The format for the relative time is:

 

keyword+/-offset+/-offset…

where keyword and offset are as specified in the table below. Whitespace is ignored. The time string must begin with a keyword. Each offset must be preceded by a signed integer that specifies the number and direction of the offset. If the integer preceding the offset is unsigned, the value of the preceding sign is assumed (beginning default sign is positive). The keyword refers to the beginning of the specified time period. DAY means the timestamp at the beginning of the current day (00:00 hours, midnight), MONTH means the timestamp at the beginning of the current month, etc.

For example, “DAY -1D+7H30M” could represent the start time for data request for a daily report beginning at 7:30 in the morning of the current day (DAY = the first timestamp for today, -1D would make it the first timestamp for yesterday, +7H would take it to 7 a.m. yesterday, +30M would make it 7:30 a.m. yesterday (the + on the last term is carried over from the last term).

Similarly, “MO-1D+5h” would be 5 a.m. on the last day of the previous month, “NOW-1H15M” would be an hour and fifteen minutes ago, and “YEAR+3MO” would be the first timestamp of April 1 this year.

Resolving relative timestamps is based upon what Microsoft has done with Excel, thus for various questionable time strings, we have these results:

10-Jan-2001 + 1 MO = 10-Feb-2001

29-Jan-1999 + 1 MO = 28-Feb-1999

31-Mar-2002 + 2 MO = 30-May-2002

29-Feb-2000 + 1 Y = 28-Feb-2001

 

In handling a gap in the calendar (due to different numbers of days in the month, or in the year), when one is adding or subtracting months or years:

 

Month: if the answer falls in the gap, it is backed up to the same time of day on the last day of the month.

Year: if the answer falls in the gap (February 29), it is backed up to the same time of day on February 28.

 

Note that the above does not hold for cases where one is adding or subtracting weeks or days, but only when adding or subtracting months or years, which may have different numbers of days in them.

 

Note that all keywords and offsets are specified in uppercase.

 

Keywords

 

NOW

The current UTC time as calculated on the server.

 

SECOND

The start of the current second.

 

MINUTE

The start of the current minute.

 

HOUR

The start of the current hour.

 

DAY

The start of the current day.

 

WEEK

The start of the current week.

 

MONTH

The start of the current month.

 

YEAR

The start of the current year.

 

Offsets

 

S

Offset from time in seconds.

 

M

Offset from time in minutes.

 

H

Offset from time in hours.

 

D

Offset from time in days.

 

W

Offset from time in weeks.

 

MO

Offset from time in months.

 

The preceding material used in accordance with the License Grant:

 

Subject to the terms and conditions of this Agreement, the OPC Foundation hereby grants to User a non-exclusive, royalty-free, limited license to use, copy, display and distribute the OPC Materials in order to make, use, sell or otherwise distribute any products and/or product literature that are compliant with the standards included in the OPC Materials. User may not distribute OPC Materials outside of the Active Member organization to which User belongs unless the OPC Foundation has explicitly designated the OPC Material for public use.

All copies of the OPC Materials made and/or distributed by User must include all copyright and other proprietary rights notices included on or in the copy of such materials provided to User by the OPC Foundation.

The OPC Foundation shall retain all right, title and interest (including, without limitation, the copyrights) in the OPC Materials, subject to the limited license granted to User under this Agreement.