1 00:00:00,730 --> 00:00:07,030 The interval data type is useful for easy to understand calculations on date and time data. 2 00:00:07,060 --> 00:00:12,220 For example, let's say you have a column that holds the date a client signed a contract. 3 00:00:12,220 --> 00:00:18,820 So using interval data, you can add 90 days to each contract date to determine when to follow up with 4 00:00:18,820 --> 00:00:19,600 the client. 5 00:00:19,630 --> 00:00:25,060 So to see interval how interval data type works, we will use. 6 00:00:26,160 --> 00:00:29,700 Uh, date time types table. 7 00:00:30,580 --> 00:00:32,020 That we have just created. 8 00:00:32,030 --> 00:00:33,700 Let's actually hear. 9 00:00:34,580 --> 00:00:35,930 Date time type state. 10 00:00:36,060 --> 00:00:41,780 Table that we just created column interval we have just two columns, interval, column and timestamp 11 00:00:41,780 --> 00:00:42,830 column and interval column. 12 00:00:43,190 --> 00:00:51,200 And here we have we will write select timestamp, column and interval column. 13 00:00:51,200 --> 00:00:57,620 And after that we will add timestamp column minus negative here. 14 00:00:57,620 --> 00:01:00,620 Interval column. 15 00:01:00,920 --> 00:01:02,750 Actually, let's go to new line. 16 00:01:02,750 --> 00:01:03,440 So. 17 00:01:04,220 --> 00:01:05,160 And have a column. 18 00:01:05,580 --> 00:01:09,990 And after that, we will add a timestamp column minus. 19 00:01:10,020 --> 00:01:11,250 Interval. 20 00:01:11,280 --> 00:01:15,870 Column as new date from. 21 00:01:17,080 --> 00:01:17,830 From. 22 00:01:20,610 --> 00:01:21,120 Date. 23 00:01:22,230 --> 00:01:23,580 Time, times. 24 00:01:23,820 --> 00:01:24,660 That's it. 25 00:01:25,200 --> 00:01:25,920 Let's run it. 26 00:01:26,970 --> 00:01:28,590 They have a time lapse. 27 00:01:31,630 --> 00:01:31,960 Here. 28 00:01:32,440 --> 00:01:39,310 So this is a typical select statement, except we will compute a column called New Date here. 29 00:01:40,180 --> 00:01:41,740 Uh, that contains. 30 00:01:42,800 --> 00:01:50,120 And it contains the result of timestamp columns minus interval column and composite columns are called 31 00:01:50,120 --> 00:01:52,420 expressions, and we will use this technique often. 32 00:01:52,430 --> 00:01:58,400 So in each row we subtract the unit of time indicated by the interval data type from the date. 33 00:01:58,400 --> 00:02:02,840 So this produces the result here, as you can see here. 34 00:02:02,900 --> 00:02:11,300 So also keep in mind that new date column by default is formatted as a timestamp with time zone allowing 35 00:02:11,300 --> 00:02:17,660 for the display of time values as well as the dates if the interval values uses them. 36 00:02:18,850 --> 00:02:19,600 So. 37 00:02:20,770 --> 00:02:26,170 You can see the data type listed in the Pgadmin results crate listed beneath the column names here. 38 00:02:26,990 --> 00:02:31,640 Again, your output may be different based on your time zone.