Okay.
The next thing I want to show you is how we could insert somebody or a row into a table where we don't
have to write the current date and the current time, but instead can get the actual current date.
The actual current time dynamically.
Because I mean, even if I knew exactly the time of the day down to the minute, well, the seconds
is going to change by the time I run my query.
So if I want to do something based off of the current date or time or date time, we have a couple of
built in functions that we can work with.
So just like we had a bunch of functions to work with, strings, which we saw earlier, things like
canned cat and upper and lower.
There's a bunch of functions on the docks that have to do with dates and times, and we're not going
to learn all of these.
There's a lot of them, but most of them are actually pretty simple.
But within this grouping there are current date, current time and current time stamp, which we're
not going to worry about right now.
And then there's also Curr date, which is a shorter version cur time and then there is now an O and
the three that I want to call your attention to right now are cur date and then cur time and now.
Now those are actually shorter versions of current dates, current time and current time stamp.
That's a little longer.
So I usually just do cur date cur time and now, but they're the same thing.
So let me just show you how they work in a simple select like select cur time that gives me the current
time and it is indeed 255 or 1455 and 40 seconds for me.
If I do cur date you can see oops, I had two semicolons so I got this extra error.
But the current date is October 5th of 2022.
I can't believe it's October already.
Yikes.
And then I have now as the other option and this gives me the current date time.
So both the date and the time in that format.
So I probably don't need to use my SQL as a calendar or as a clock, but I can.
And just as a reminder, we could write it this way if you prefer current time instead of cur time.
It's just shorter to do cur time.
It's the same situation as upper and you case we have a shorter version, but they mean the same thing.
So we have current date which can be shortened to cur date.
Current time becomes cur time, but then if we have current time stamp, well that gets shortened just
to now.
And that gives us the same result.
Of course, I ran it later.
So the seconds have changed, but other than that, it's the same result.
So we could use this.
If I wanted to insert a new person into my database, somebody who is just born into people.
Let's just do the same order.
Birth, date, birth time and birth date.
Make sure I spell date correctly and for values will pick a name like.
Sure.
Hazel.
So Hazel was born right now.
So for the dates portion, I'll do her date.
And then for the time portion, I'll do her time.
And then don't forget, it's not her date time.
It's current time stamp or now.
Now is easier to type.
All right, so let's insert Hazel.
She was just born.
Select star from people.
And there's Hazel.
And we see the current date, the current time, and the current date time that we ran that query.
So of course, if I ran it again, we would see a different time and a different date time.
Here.
The date would be the same.
It's still the same day, but this is a really useful set of functions we can use if we ever need to
access anything about the current date, time or date time.
Next up, we're going to take a look at some of these other date and time functions.
So we saw the current date, time, date time stuff.
But what about things like month or minute or day of week, day name?
We're going to see all of that coming up next.