1 00:00:00,120 --> 00:00:05,490 Next, we're going to move on to a handful of different data types that have to do with dates and times. 2 00:00:05,490 --> 00:00:07,320 So it's a little bit different. 3 00:00:07,680 --> 00:00:14,010 Well, very different from working with numbers or just pieces of text because we get a bunch of functionality 4 00:00:14,010 --> 00:00:19,950 along with dates and times so that we could do some basic math, for example, between dates, or that 5 00:00:19,950 --> 00:00:26,010 we can pull out the number of minutes from a time or the month of the year from a date. 6 00:00:26,010 --> 00:00:28,260 So there's some extra stuff we need to cover. 7 00:00:28,260 --> 00:00:33,000 But in this video, I just want to introduce the basic types that we'll be working with. 8 00:00:33,000 --> 00:00:36,870 And the first of these types is date, just straight date. 9 00:00:36,870 --> 00:00:37,890 It's very simple. 10 00:00:37,920 --> 00:00:43,230 It stores a date with no time involved, just a particular date. 11 00:00:43,230 --> 00:00:44,640 And it's in this format. 12 00:00:44,760 --> 00:00:50,640 It's always a four digit year dash two digit month, dash two digit day. 13 00:00:50,640 --> 00:00:58,110 So very different than the way us Americans store our dates or everyone else in the world who does what 14 00:00:58,110 --> 00:00:59,700 is it, day first and then month. 15 00:00:59,700 --> 00:01:02,670 For whatever reason in the US we do month and then day. 16 00:01:02,670 --> 00:01:08,970 But both of those are different than what my SQL does, which is year first, then month and then day. 17 00:01:09,360 --> 00:01:12,750 So we could use this to store all sorts of dates. 18 00:01:12,750 --> 00:01:20,370 For example, you know, the day somebody was born, if you sign up for a website, usually if you have 19 00:01:20,370 --> 00:01:24,960 to select a birth date, you're putting a date in, but you're not putting a time of day in all of that 20 00:01:24,960 --> 00:01:25,650 other stuff in. 21 00:01:25,650 --> 00:01:27,240 It's just a straight date. 22 00:01:27,450 --> 00:01:34,440 You could also use dates for if we wanted to build a calendar app and we needed to have holidays, they 23 00:01:34,440 --> 00:01:37,860 occur on a particular day or events we're having. 24 00:01:37,860 --> 00:01:38,130 I don't know. 25 00:01:38,130 --> 00:01:39,540 We're putting on a marathon. 26 00:01:39,540 --> 00:01:41,670 What is the day of the marathon? 27 00:01:41,670 --> 00:01:42,780 Dates come up all the time. 28 00:01:42,780 --> 00:01:46,500 Those are kind of mediocre examples, but there's a lot of situations. 29 00:01:46,500 --> 00:01:48,870 We would use dates and then we have time. 30 00:01:48,870 --> 00:01:52,230 So the data type time can it's a little flexible. 31 00:01:52,230 --> 00:02:01,290 It can represent the time of a day like 12:00 or 1301 or five in the morning. 32 00:02:01,860 --> 00:02:06,000 So we could do things like, you know, use a time data type. 33 00:02:06,420 --> 00:02:12,870 If you were building a reminder application that would set an alarm and wake you up at six in the morning. 34 00:02:12,870 --> 00:02:20,250 You can use time, but it also can represent an amount of time or an interval of time. 35 00:02:20,250 --> 00:02:24,180 So think of how long somebody took to finish our marathon. 36 00:02:24,180 --> 00:02:31,440 If we were putting on our marathon and we had a participant table, every participant would have a time 37 00:02:31,440 --> 00:02:40,440 or a race time or completion time, total time, and that might be 2 hours and a half for some fast 38 00:02:40,440 --> 00:02:40,680 people. 39 00:02:40,680 --> 00:02:42,690 It might be 4 hours, it might be 6 hours. 40 00:02:42,690 --> 00:02:46,290 It's not a time of day, it's just an amount of time. 41 00:02:46,650 --> 00:02:48,990 So we can use time to store that. 42 00:02:49,170 --> 00:02:56,490 But the format that we use for time is always hours and then minutes and then seconds separated by colons. 43 00:02:56,580 --> 00:02:58,440 And the dox goes into this. 44 00:02:58,440 --> 00:03:01,950 If you want to take a look, there's a lot of information about the time type. 45 00:03:02,670 --> 00:03:07,590 This is just sort of the intro page, but you can learn more about times, but it does show us that 46 00:03:08,070 --> 00:03:15,390 we can technically store times from -830 8 hours up to positive 838 hours. 47 00:03:15,390 --> 00:03:21,450 So once again, it's not only a time in in a day where there's 24 hours, but it can actually represent 48 00:03:21,450 --> 00:03:24,810 an interval of time, including a negative amount of time. 49 00:03:25,290 --> 00:03:27,030 And then we have date time. 50 00:03:27,180 --> 00:03:28,740 It's a date with a time. 51 00:03:29,310 --> 00:03:31,230 So it follows this format. 52 00:03:31,230 --> 00:03:37,350 We have the year dash month, dash day, and then a space and then a time. 53 00:03:37,470 --> 00:03:43,620 So our minutes, seconds, separated by colons and date time is actually quite useful. 54 00:03:43,650 --> 00:03:49,170 There's a lot of information you might want to store, not just the date, but also the time usually 55 00:03:49,560 --> 00:03:55,230 of particular events that have happened when something was last changed or when something was created 56 00:03:55,230 --> 00:04:02,190 when a user joined our website, when they signed up for an account, or if we let users set up appointments 57 00:04:02,190 --> 00:04:05,190 or schedule something on a calendar application. 58 00:04:05,190 --> 00:04:08,820 And there's a million examples where we have a date and a time together. 59 00:04:09,090 --> 00:04:12,660 Now, of course, if you only need a date, you probably just want to use date. 60 00:04:12,660 --> 00:04:14,550 If you only need a time, you can use time. 61 00:04:14,550 --> 00:04:22,590 But if you want a date and time of some particular moment in time, you can use date time and to confuse 62 00:04:22,590 --> 00:04:23,670 things even further. 63 00:04:23,670 --> 00:04:28,440 Later on in this section, we're going to see something called timestamps, which also stores a date 64 00:04:28,440 --> 00:04:29,130 in a time. 65 00:04:29,130 --> 00:04:33,390 But we're going to start in the next video by working with some of these or some of these data types 66 00:04:33,390 --> 00:04:36,180 and making a table that includes these values. 67 00:04:36,180 --> 00:04:37,110 So that's coming up.