DateAdd(...) Expressions
- Last UpdatedMar 18, 2021
- 1 minute read
Note: Extended stored procedures are no longer supported.
Date/time values can have a string value expression containing the string "DateAdd(…)". This is not the same as the SQL Server DateAdd() function, although the effect is very similar.
Syntax
"DATEADD (datepart, number, date)"
Parameters
DatePart
Specifies on which part of the date to return a new value. The following table lists the date parts and abbreviations recognized by the extended stored procedures for the AVEVA Historian.
|
MILLISECOND |
MS |
|
SECOND |
SS |
|
MINUTE |
MI |
|
HOUR |
HH |
|
DAY |
DD |
|
WEEKDAY |
DW |
|
WEEK |
WK |
|
DAYOFYEAR |
DY |
|
MONTH |
MM |
|
QUARTER |
|
|
YEAR |
YY |
Number
The value used to increment datepart. If you specify a value that is not an integer, the fractional part of the value is discarded. For example, if you specify day for datepart and 1.75 for number, date is incremented by 1.
Date
Either a literal date value without quotes (see Literal Date Expressions) or a GetDate() expression also without quotes (see GetDate() Expressions).
Example Expressions
"DateAdd(HOUR, -1, GetDate())"
"DateAdd(MINUTE, -30, 4/2/2001 13:00:00:00)"
Extended Stored Procedure Date Expression Examples
xp_DiscreteHistory "DateAdd(HOUR, -1, GetDate())", "GetDate()", 1000, 'SysPulse'
xp_DiscreteHistoryDelta "DateAdd(DAY, -1, 4/2/2001)", "GetDate()", 100, 'SysPulse'