All right.
So in this video let me go ahead and look at the age function in PostgreSQL.
All right.
So we're going to deal with age function.
And what we're going to run into the big problem.
Yes.
The big problem we're going to run is that when I was creating this I was creating this the enrolled
date as from 2014 to 2015.
This is the year that never existed before now.
And, uh, I should have gone to, uh, actually in, uh, create in road dates from 1980 or 2000,
anything maybe 2000 below 2020 and so on.
What I want for us 2014 to 2015.
All right.
Now, if I were to get each of each of these people, maybe from the time they enrolled into the school
to date, I should be getting negative date or negative age.
What if I've done this from maybe 19 something, or now I should be getting the age?
Let me say seven years ago, eight years ago or nine years ago.
What now?
If I should go ahead and do that from 2040, 2050, which never existed, is going to start from maybe
minus seven years, -20 years, -18, -16 and so on.
But I need to introduce us to these.
That is why I want to make this video.
So you can go ahead and are great in new, uh, data sets from macro.
You can drop this table and uh, change it or enroll date to 19.
Anything you understand so that this date can actually match.
But for the sake of this course and for us having the knowledge, I want to actually explain this before
we go ahead and check the age of the students.
All right.
Let me go ahead and see.
I want to select all from students or acquire head and select maybe the first underscore name, and
I will select the last underscore name.
And uh I will also select the in row underscore.
Did you understand.
Now I will introduce an h function.
And this h function accepts two arguments.
The very first argument is a timestamp.
We are going to start now where we are taking this lecture to the age 2042, to know the age that the
students enrolled.
And that is going to give us minus which is not proper.
But if we have done enroll date to be something better off, maybe like 1960, 1970, 1989, 2000 and
so on, it might be like 17 years ago.
Now let's go ahead and introduce that H function.
And I want to show us this.
So the function, the very first the text, the timestamp, the very first one is noun.
So starting from now we want to check out dates.
And you insert the a row underscore date.
So this is a quorum we want to actually check.
And we're going to create a new quorum to actually give us the age of the student.
And for us to do that we're going to create that new quorum as age or as students.
Students underscore age.
Okay.
Now we can go ahead and execute this query and check it out.
Now, just like I explained, you can see that our Macron alone enrolled on this.
And that is -70 is a goal.
And the negative term ones and the -20 days and the time the person enrolled.
So this is the time stamp on the submit this to be like in 1920, 1989, 1960, 17 and so on.
You might have something better.
And that should be like 17 years, three months ago.
2020, three days ago and so on.
So I think I explained this sort of actually know why we are having negative e.
Okay.
So you can actually go ahead and add a create a new macro dataset.
Then drop this table is set or you know new table right in here.
And now actually create a new table called a student's age.
Or students are vacation or the time they actually graduated or the graduation age.
Okay, so I hope that is cool.
So go ahead and check it out.
I just want to introduce this.
So can be able to know how to add or take in this function known as the age function is very important
in PostgreSQL.
So go ahead and check it out.
And if you have any questions go ahead and use the question and answer section.
And I'm going to get back to you as soon as possible.
Thank you so much.
And I'm going to see you in the next video lecture.