The interval data type is useful for easy to understand calculations on date and time data.
For example, let's say you have a column that holds the date a client signed a contract.
So using interval data, you can add 90 days to each contract date to determine when to follow up with
the client.
So to see interval how interval data type works, we will use.
Uh, date time types table.
That we have just created.
Let's actually hear.
Date time type state.
Table that we just created column interval we have just two columns, interval, column and timestamp
column and interval column.
And here we have we will write select timestamp, column and interval column.
And after that we will add timestamp column minus negative here.
Interval column.
Actually, let's go to new line.
So.
And have a column.
And after that, we will add a timestamp column minus.
Interval.
Column as new date from.
From.
Date.
Time, times.
That's it.
Let's run it.
They have a time lapse.
Here.
So this is a typical select statement, except we will compute a column called New Date here.
Uh, that contains.
And it contains the result of timestamp columns minus interval column and composite columns are called
expressions, and we will use this technique often.
So in each row we subtract the unit of time indicated by the interval data type from the date.
So this produces the result here, as you can see here.
So also keep in mind that new date column by default is formatted as a timestamp with time zone allowing
for the display of time values as well as the dates if the interval values uses them.
So.
You can see the data type listed in the Pgadmin results crate listed beneath the column names here.
Again, your output may be different based on your time zone.