Time and Date Operators

When using time and date operators, you should explicitly prefix the corresponding operands with type modifiers to ensure that the database parses the operands as intended, avoiding unexpected results.
For example, failing to specify the data type in the following query will cause an exception.
1
|
SELECT date '2001-10-01' - '7' AS RESULT; |
Operator |
Example |
|||
---|---|---|---|---|
+ |
Add a date type parameter and an integer parameter to get the time after 7 days.
|
|||
Add a date type parameter and an interval parameter to get the time after 1 hour.
|
||||
Add a date type parameter and an interval parameter to get the time span of 1 month. The date function adjusts the date range beyond the month to align with the last day of the respective month. It leaves the date range unchanged if it does not exceed the month.
|
||||
Add a date type parameter and a time type parameter to get a specific date and time result.
|
||||
Add interval parameters to get the sum of two time spans.
|
||||
Add a timestamp type parameter and an interval parameter to get the time after 23 hours.
|
||||
Add a time type parameter and an interval parameter to get the time after 3 hours.
|
||||
- |
Subtract date type parameters to get the time difference between two dates.
|
|||
Subtract an integer parameter from a date type parameter and return a timestamp type to get the time difference between them.
|
||||
Subtract an interval parameter from a date type parameter to get the date and time difference.
|
||||
Subtract time type parameters to get the time difference between them.
|
||||
Subtract an interval parameter from a time type parameter to get the time difference between them.
|
||||
Subtract an interval from a timestamp to get the date and time difference between them.
|
||||
Subtract interval parameters to get the time difference between them.
|
||||
Subtract timestamp type parameters to get the date and time difference between them.
|
||||
Get the previous day from the current date.
|
||||
* |
Multiply a time span by a quantity.
|
|||
|
||||
|
||||
/ |
Divide a time span by a quantity to get a segment within a period of time.
|
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot