Next, we're going to move on to a handful of different data types that have to do with dates and times.
So it's a little bit different.
Well, very different from working with numbers or just pieces of text because we get a bunch of functionality
along with dates and times so that we could do some basic math, for example, between dates, or that
we can pull out the number of minutes from a time or the month of the year from a date.
So there's some extra stuff we need to cover.
But in this video, I just want to introduce the basic types that we'll be working with.
And the first of these types is date, just straight date.
It's very simple.
It stores a date with no time involved, just a particular date.
And it's in this format.
It's always a four digit year dash two digit month, dash two digit day.
So very different than the way us Americans store our dates or everyone else in the world who does what
is it, day first and then month.
For whatever reason in the US we do month and then day.
But both of those are different than what my SQL does, which is year first, then month and then day.
So we could use this to store all sorts of dates.
For example, you know, the day somebody was born, if you sign up for a website, usually if you have
to select a birth date, you're putting a date in, but you're not putting a time of day in all of that
other stuff in.
It's just a straight date.
You could also use dates for if we wanted to build a calendar app and we needed to have holidays, they
occur on a particular day or events we're having.
I don't know.
We're putting on a marathon.
What is the day of the marathon?
Dates come up all the time.
Those are kind of mediocre examples, but there's a lot of situations.
We would use dates and then we have time.
So the data type time can it's a little flexible.
It can represent the time of a day like 12:00 or 1301 or five in the morning.
So we could do things like, you know, use a time data type.
If you were building a reminder application that would set an alarm and wake you up at six in the morning.
You can use time, but it also can represent an amount of time or an interval of time.
So think of how long somebody took to finish our marathon.
If we were putting on our marathon and we had a participant table, every participant would have a time
or a race time or completion time, total time, and that might be 2 hours and a half for some fast
people.
It might be 4 hours, it might be 6 hours.
It's not a time of day, it's just an amount of time.
So we can use time to store that.
But the format that we use for time is always hours and then minutes and then seconds separated by colons.
And the dox goes into this.
If you want to take a look, there's a lot of information about the time type.
This is just sort of the intro page, but you can learn more about times, but it does show us that
we can technically store times from -830 8 hours up to positive 838 hours.
So once again, it's not only a time in in a day where there's 24 hours, but it can actually represent
an interval of time, including a negative amount of time.
And then we have date time.
It's a date with a time.
So it follows this format.
We have the year dash month, dash day, and then a space and then a time.
So our minutes, seconds, separated by colons and date time is actually quite useful.
There's a lot of information you might want to store, not just the date, but also the time usually
of particular events that have happened when something was last changed or when something was created
when a user joined our website, when they signed up for an account, or if we let users set up appointments
or schedule something on a calendar application.
And there's a million examples where we have a date and a time together.
Now, of course, if you only need a date, you probably just want to use date.
If you only need a time, you can use time.
But if you want a date and time of some particular moment in time, you can use date time and to confuse
things even further.
Later on in this section, we're going to see something called timestamps, which also stores a date
in a time.
But we're going to start in the next video by working with some of these or some of these data types
and making a table that includes these values.
So that's coming up.