WEBVTT

00:07.730 --> 00:08.210
All right.

00:08.210 --> 00:13.970
So in this video let me go ahead and look at the age function in PostgreSQL.

00:14.870 --> 00:15.230
All right.

00:15.260 --> 00:17.240
So we're going to deal with age function.

00:17.270 --> 00:20.300
And what we're going to run into the big problem.

00:20.330 --> 00:21.440
Yes.

00:21.470 --> 00:27.410
The big problem we're going to run is that when I was creating this I was creating this the enrolled

00:27.410 --> 00:31.760
date as from 2014 to 2015.

00:31.790 --> 00:34.550
This is the year that never existed before now.

00:35.060 --> 00:45.830
And, uh, I should have gone to, uh, actually in, uh, create in road dates from 1980 or 2000,

00:45.860 --> 00:50.450
anything maybe 2000 below 2020 and so on.

00:50.480 --> 00:54.590
What I want for us 2014 to 2015.

00:55.190 --> 00:55.610
All right.

00:55.640 --> 01:03.920
Now, if I were to get each of each of these people, maybe from the time they enrolled into the school

01:03.950 --> 01:08.680
to date, I should be getting negative date or negative age.

01:09.430 --> 01:16.060
What if I've done this from maybe 19 something, or now I should be getting the age?

01:16.240 --> 01:20.770
Let me say seven years ago, eight years ago or nine years ago.

01:20.800 --> 01:21.370
What now?

01:21.370 --> 01:29.200
If I should go ahead and do that from 2040, 2050, which never existed, is going to start from maybe

01:29.230 --> 01:34.600
minus seven years, -20 years, -18, -16 and so on.

01:34.630 --> 01:37.480
But I need to introduce us to these.

01:37.480 --> 01:41.080
That is why I want to make this video.

01:41.080 --> 01:48.580
So you can go ahead and are great in new, uh, data sets from macro.

01:48.610 --> 01:54.460
You can drop this table and uh, change it or enroll date to 19.

01:54.490 --> 01:58.330
Anything you understand so that this date can actually match.

01:58.330 --> 02:05.350
But for the sake of this course and for us having the knowledge, I want to actually explain this before

02:05.350 --> 02:09.160
we go ahead and check the age of the students.

02:09.190 --> 02:09.730
All right.

02:09.730 --> 02:10.990
Let me go ahead and see.

02:11.020 --> 02:20.550
I want to select all from students or acquire head and select maybe the first underscore name, and

02:20.550 --> 02:23.760
I will select the last underscore name.

02:23.760 --> 02:30.090
And uh I will also select the in row underscore.

02:30.120 --> 02:32.070
Did you understand.

02:32.100 --> 02:35.610
Now I will introduce an h function.

02:35.610 --> 02:39.720
And this h function accepts two arguments.

02:39.750 --> 02:42.330
The very first argument is a timestamp.

02:42.330 --> 02:51.300
We are going to start now where we are taking this lecture to the age 2042, to know the age that the

02:51.300 --> 02:52.260
students enrolled.

02:52.260 --> 02:55.950
And that is going to give us minus which is not proper.

02:55.950 --> 03:04.860
But if we have done enroll date to be something better off, maybe like 1960, 1970, 1989, 2000 and

03:04.860 --> 03:07.860
so on, it might be like 17 years ago.

03:07.890 --> 03:10.650
Now let's go ahead and introduce that H function.

03:10.650 --> 03:12.270
And I want to show us this.

03:12.270 --> 03:17.070
So the function, the very first the text, the timestamp, the very first one is noun.

03:17.070 --> 03:20.410
So starting from now we want to check out dates.

03:20.410 --> 03:26.050
And you insert the a row underscore date.

03:26.050 --> 03:29.920
So this is a quorum we want to actually check.

03:29.950 --> 03:35.620
And we're going to create a new quorum to actually give us the age of the student.

03:35.620 --> 03:44.650
And for us to do that we're going to create that new quorum as age or as students.

03:47.440 --> 03:49.420
Students underscore age.

03:50.020 --> 03:50.470
Okay.

03:50.500 --> 03:53.620
Now we can go ahead and execute this query and check it out.

03:53.650 --> 04:01.120
Now, just like I explained, you can see that our Macron alone enrolled on this.

04:01.120 --> 04:04.300
And that is -70 is a goal.

04:04.330 --> 04:11.290
And the negative term ones and the -20 days and the time the person enrolled.

04:11.290 --> 04:20.380
So this is the time stamp on the submit this to be like in 1920, 1989, 1960, 17 and so on.

04:20.410 --> 04:21.610
You might have something better.

04:21.610 --> 04:24.250
And that should be like 17 years, three months ago.

04:24.280 --> 04:27.790
2020, three days ago and so on.

04:28.120 --> 04:32.890
So I think I explained this sort of actually know why we are having negative e.

04:32.920 --> 04:33.400
Okay.

04:33.430 --> 04:38.200
So you can actually go ahead and add a create a new macro dataset.

04:38.230 --> 04:43.870
Then drop this table is set or you know new table right in here.

04:43.870 --> 04:49.210
And now actually create a new table called a student's age.

04:49.210 --> 04:59.020
Or students are vacation or the time they actually graduated or the graduation age.

05:00.190 --> 05:01.930
Okay, so I hope that is cool.

05:01.930 --> 05:03.370
So go ahead and check it out.

05:03.370 --> 05:04.600
I just want to introduce this.

05:04.600 --> 05:11.950
So can be able to know how to add or take in this function known as the age function is very important

05:11.950 --> 05:13.030
in PostgreSQL.

05:13.030 --> 05:14.380
So go ahead and check it out.

05:14.380 --> 05:17.410
And if you have any questions go ahead and use the question and answer section.

05:17.410 --> 05:19.840
And I'm going to get back to you as soon as possible.

05:19.870 --> 05:20.800
Thank you so much.

05:20.800 --> 05:24.070
And I'm going to see you in the next video lecture.
