Hey there.
So I have a small confession to make at the beginning of this video.
This is not my first time recording this.
I recorded this about a month ago, along with all the other videos in this section, and something
happened.
I didn't save it correctly.
I maybe accidentally deleted it.
My cat stepped on the keyboard.
I have no idea, but the original video here is gone and normally that wouldn't be a problem.
It's happened before.
Or I just rerecord a section because I'm not happy with it.
That's not too bad.
It's easy to do.
But since this has to do with dates and in particular it has to do with these three date functions that
I'm going to show you.
Basically, they give us the current date, the current time and the current date time.
You'll see in the videos following this one that the code that I ran when I was recording it the first
time resulted in different dates and different times than what you'll see right now.
So it's not a big deal at all.
It's just evidence that I recorded them on different times, but I wanted to just let you know what
to expect.
Okay, so in the last video, we inserted these to where we manually created or basically wrote out
the dates, the time and the date time.
And then in the initial recorded version of this video, this is the new person that I inserted.
And this birth date, birth time and birth date time were all done using these three functions here
that give the current birth, the current date.
So at the time it was April 21st and the time was 712 and this was the date time.
And so I used these to generate this.
So in the next video you will see this person with Towcester birth date, April 20, 21st and so on.
But in this video where I'm actually showing you the creation, I'm having to rerecord it.
So there's just a small discrepancy.
Other than that, everything else will be the same.
So let me show you these three methods here.
They're really useful, simple things, but Curr Date gives current date.
As I said, current time gives the current time and then now gives current date time.
So let's try one of them just on their own.
If you did something like Select Curr Date, you'll see that I'm actually recording this on 512 May
12, so not quite a month later, but a couple of weeks later.
So if we do the same thing with Curr Time.
We get the time and then if we do now we get the date time.
So using them on their own is not useful really.
Just to select the current time.
It's much easier just to look at your watch.
But they become useful when we use them in conjunction with insert statements.
So things like when we're inserting a new user and we want to save the time that the user was inserted.
What we could do is basically write an insert into and we'll do people let's do our select start from
people.
So we'll do insert into people birth date, birth time and birth date time.
And so I think the hypothetical story I gave was that toaster was my son, my first son, and he was
born exactly at the moment when I hit enter.
So we'll do the same thing here, inserting into people birth date, birth time, birth date time.
This will be my new son and this one's name is let me actually add a name as well.
Oh, boy.
I'm really bad at naming things, as you can tell, and named my cat blue, which is blue steel, by
the way, if you didn't catch that.
Okay, so I'll name him microwave.
And then rather than writing out the giant date here, what I'll do instead is for the birth date.
I just say her date and then for the birth time I'll just use cur time and then for birth date time
I use now.
And out of all of these, I end up using now the most often, because as I've mentioned before, we
use date times a lot.
Okay.
So if we just run this right now and insert that and now we do our select star from people, you can
see that microwave now has the date, the time and the date time that reflect exactly when I inserted
this just a couple of seconds ago, and that's pretty much all there is to these three nice little functions.
Another way that we use them, by the way, is not just to insert data with current dates and times
and so on, but also to compare data to the current time.
So I'll show you how to do some basic date math.
We'll be able to figure out how long ago something was compared to now.
And so we need to be able to refer to now or we want to figure out how many dates, you know, how many
days somebody was born ago compared to the current date.
So we need that current date in order to help out with that math.
Okay.
So the last thing I'll do here just for continuity sake is delete microwave so that we have toaster,
Larry and Padma, which is what I had in the original recording, so that the next video here hopefully
will be relatively seamless.
So I'm getting rid of my sun.
I'm sorry, microwave.
I failed you.
Okay, so now he's gone and we're back to these three.
All right, so that's Curr Date Card Time and now.