Skip to main content
Time operators in Oxla allow you to perform various operations on dates, times, and intervals. Here’s a guide to using these operators:

1. DATE + INTEGER

Add a specific number of days to a date. Example
The result will be 14 days after ‘2022-03-15’.

1.1. INTEGER + DATE

Adding and multiplying time operators can also be done in reverse order. For example, we add a number of days to a date in the format of Integer + Date.
The result will be the same, which is 14 days after ‘2022-03-15’ is ‘2022-03-29’.

2. DATE + INTERVAL

Add a specified interval to a date. Example
The result will be the date three months after ‘2022-03-15’.

3. DATE - INTEGER

Subtract a certain number of days from a date. Example
The result will be 7 days before ‘2022-03-15’.

4. DATE - INTERVAL

Subtract a specified interval from a date. Example
The result will be the timestamp with two hours before ‘2022-03-15’.

5. DATE - DATE

Subtract dates. Example
The number of days elapsed between ‘2023-03-15’ and ‘2023-01-10’ is 64 days.

6. DATE + TIME

Add a time-of-day to a date. Example
The result will be a timestamp with the specified time added to the given date.

7. TIME + INTERVAL

Add a certain interval to a given time. Example
The result will be the time 1 hour after ‘12:30’.

8. TIME - INTERVAL

Subtract a specified interval from a given time. Example
The result will be the time 18:00.

9. TIME - TIME

Get a time difference by subtracting one time from another. Example
In this example, the time difference between the two provided times is 1 hour and 40 minutes.

10. TIMESTAMP + INTERVAL

Add a timestamp and an interval. Example
The result will be a new timestamp, adding 5 days to ‘2021-01-05 12:00:00’.

11. TIMESTAMP - INTERVAL

Subtract an interval from a timestamp. Example
In this example, it subtracts 3 days from ‘2022-01-04 12:00:00’.

12. TIMESTAMP - TIMESTAMP

Get an interval by subtracting one timestamp from another. Example
It gives the interval between the two timestamps, 102 hours and 30 minutes.

13. INTERVAL + INTERVAL

Add intervals. Example
It adds 6 days to 2 days, resulting in a total of 2 months and 8 days.

14. INTERVAL - INTERVAL

Subtract intervals. Example
It subtracts 20 days from 2 months.

15. INTERVAL * INTEGER

Multiply an interval by an integer. Example
It multiplies ‘2 hours’ by 3, the result is 6 hours.

16. INTERVAL * DOUBLE PRECISION

Multiply an interval by a scalar. Example
It multiplies ‘2 hours’ by 1.5, and returns 3 hours.

17. INTERVAL / NUMBER

Divide an interval by an integer or scalar.

a) Divide by an integer

It divides ‘1 hour’ by 2, and returns 30 minutes.

b) Divide by a scalar

It divides ‘2 hours’ by 1.5, and returns 1 hour 20 minutes.