Introduction
Dates
Time
Timestamps
Extract functions
Timezone conversion
Intervals
33. INTERVAL with constant values – continued
Current date and time
Revision

Instruction

The addition failed because our database thinks that '2015-01-01' is a common text value (string) and it's not able to add an interval to a text field. What can we do, then? We can explicitly convert '2015-01-01' to a date/timestamp:

SELECT CAST('2015-01-01' AS timestamp) + INTERVAL '5' DAY;

Let's see if it works.

Exercise

Run the new template to see if this query works.

Console

Code editor

Result

TableConsole