Date and Time Operators
When you use date and time operators, add prefixes of explicit types to the operands to ensure that the operands can be properly parsed by the database.
For example, the operand in the following example does not have an explicit data type, and an error will occur.
1
|
SELECT date '2001-10-01' - '7' AS RESULT; |
Operator |
Example |
|||
---|---|---|---|---|
+ |
Add a date with an integer to obtain the time after 7 days.
|
|||
Add a date with an interval to obtain the time after 1 hour.
|
||||
Add a date with an interval to obtain the time after 1 month. If the sum or subtraction results fall beyond the date range of a month, the result will be rounded to the last day of the month.
|
||||
Add a date and a time to obtain a specific time.
|
||||
Add two intervals to obtain the sum.
|
||||
Add a timestamp and an interval to obtain the time after 23 hours.
|
||||
Add a time and an interval to obtain the time after three hours.
|
||||
- |
Subtract a date from another to obtain the time difference.
|
|||
Subtract an integer from a date to obtain the difference.
|
||||
Subtract an interval from a date to obtain the date and time difference.
|
||||
Subtract a time from another time to obtain the time difference.
|
||||
Subtract an interval from a time to obtain the time difference.
|
||||
Subtract an interval from a timestamp to obtain the date and time difference.
|
||||
Subtract an interval from another interval to obtain the time difference.
|
||||
Subtract a timestamp from another timestamp to obtain the time difference.
|
||||
Obtain the time on the previous day.
|
||||
* |
Multiply an interval by a quantity.
|
|||
|
||||
|
||||
/ |
Divide an interval by a quantity to obtain a time segment.
|
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