![]() Previous |
![]() Next |
A date-only expression is an expression that evaluates to the OLAP DML DATE
data type as discussed in "Date-only Data Type". The expression might be a function that returns a date-only value, a date-only literal, or a more complex expression.
Calculating DATE-only Values
You can add numbers to a DATE
value, or subtract numbers from them. Whole numbers are calculated as days, and decimal values are calculated as fractions of a day. For example, SYSDATE+1.5
adds 1 day and 12 hours to the current date and time. You cannot divide or multiply DATE
values, and you cannot subtract them from numbers. For example, 1-SYSDATE
and 1*SYSDATE
return errors.
Using DATE-only Values in Arithmetic Expressions
When you use DATE values in arithmetic expressions, the result can be numeric or it can be a date. The legal operations for dates and the data type of the result are outlined in Table: Legal Operations for DATE Values.
Legal Operations for DATE Values
Operation | Result |
---|---|
Add or subtract a number from a date |
Future or prior date |
Subtract a date from a date |
The number of days between the dates. |
Add or subtract a number from a time period. |
The time period at the appropriate interval in the future or the past, similar to the return values of the LEAD or LAG function. The result is NA when there is no dimension value that corresponds to the result. The calculation is made based on the positions of the values in the default status list of the dimension. |