1 00:00:00,150 --> 00:00:00,630 All right. 2 00:00:00,630 --> 00:00:06,360 So we've made it through that war zone of string and number types in particular. 3 00:00:06,360 --> 00:00:11,490 The number types are always a bit hairy, but we're moving on to something equally finicky. 4 00:00:11,490 --> 00:00:19,410 Dates and times are often the bane of many programmers existence, having to deal with time zones and 5 00:00:19,410 --> 00:00:23,100 synchronizing things across the world and daylight savings. 6 00:00:23,130 --> 00:00:24,570 It's just a nightmare leap year. 7 00:00:24,570 --> 00:00:27,930 Fortunately, my SQL makes it relatively simple for us. 8 00:00:28,200 --> 00:00:31,440 I'm going to show you how in just next couple of videos. 9 00:00:31,440 --> 00:00:34,380 So this is going to be a series here, not just a single video. 10 00:00:34,380 --> 00:00:38,940 And in fact, in this first video, I'm just going to give you a quick overview of the three important 11 00:00:38,940 --> 00:00:40,590 data types that we'll take a look at. 12 00:00:41,130 --> 00:00:43,860 So the first one is called date. 13 00:00:44,310 --> 00:00:48,300 And what it does is it just stores a date without a time. 14 00:00:48,780 --> 00:00:51,150 So the format looks like this. 15 00:00:51,600 --> 00:00:53,370 Yea yea yea yea yea. 16 00:00:53,370 --> 00:00:55,710 Dash month month dash de day. 17 00:00:55,710 --> 00:01:01,560 So 1999, dash 11, dash 25 or something. 18 00:01:01,560 --> 00:01:05,370 So as it states here that that store is a date but no time. 19 00:01:05,370 --> 00:01:09,510 So there are instances where you may use this, things like a birthday. 20 00:01:09,510 --> 00:01:17,160 If you're asking a user to sign up and specify their birthday, most users don't know the time. 21 00:01:17,220 --> 00:01:18,240 Well, I don't know. 22 00:01:18,240 --> 00:01:19,440 I don't know the time I was born. 23 00:01:19,440 --> 00:01:24,270 I know a lot of people do, but it doesn't matter, at least for most websites. 24 00:01:24,270 --> 00:01:26,130 It doesn't matter what time someone was born. 25 00:01:26,130 --> 00:01:27,540 You just need that date. 26 00:01:29,060 --> 00:01:32,510 Another option is the opposite the time. 27 00:01:32,900 --> 00:01:38,130 So time is another data type that stores values with a time but no date. 28 00:01:38,150 --> 00:01:43,430 So out of the three, I'm going to show you, this is the one I use the least by far, because there's 29 00:01:43,430 --> 00:01:46,610 not many things that you just need to store a time. 30 00:01:47,150 --> 00:01:56,450 Maybe if you're I don't know if you're working with reminders, maybe like or working, I'm at a loss 31 00:01:56,450 --> 00:01:56,750 really. 32 00:01:56,750 --> 00:02:04,830 But basically store times and the syntax, the format is our our dash or excuse me, colon, minute, 33 00:02:04,860 --> 00:02:07,130 minute, colon second, second. 34 00:02:07,280 --> 00:02:13,970 And the final data type and the one that I use by far the most out of all of them is date time. 35 00:02:14,760 --> 00:02:15,570 Not very creative. 36 00:02:15,570 --> 00:02:15,900 I know it. 37 00:02:15,910 --> 00:02:16,650 Just date. 38 00:02:16,650 --> 00:02:22,320 Plus time does what it sounds like, which I also realize I'm saying way too often in this course, 39 00:02:22,320 --> 00:02:27,360 but it stores values with a date and a time and this is pretty useful. 40 00:02:27,360 --> 00:02:28,320 You get both. 41 00:02:28,890 --> 00:02:31,560 And like I said, this is what I use the most. 42 00:02:31,560 --> 00:02:36,120 So when you're doing things like I don't know when a user signed up for your site or when something 43 00:02:36,120 --> 00:02:41,610 was last updated, when a profile picture was last updated, or when somebody commented on a Facebook 44 00:02:41,610 --> 00:02:42,090 post. 45 00:02:42,090 --> 00:02:47,520 Those are all stored with date times because just having the time on its own isn't that useful. 46 00:02:48,090 --> 00:02:50,010 So let's go with this Facebook example. 47 00:02:50,250 --> 00:02:57,000 If I comment on someone's post, Facebook doesn't just store the time that I commented 10:39 p.m., 48 00:02:57,000 --> 00:02:59,910 let's say, because it's just not that useful to them. 49 00:03:00,090 --> 00:03:05,670 You know, I think what Facebook does is it displays things like how many days ago or hours or minutes 50 00:03:05,670 --> 00:03:06,540 ago or something. 51 00:03:06,780 --> 00:03:15,390 I commented, It will say like Colt commented 3 seconds ago, 20 minutes ago, two days ago, last month, 52 00:03:15,390 --> 00:03:18,840 and it needs more than just a time to figure that out. 53 00:03:18,840 --> 00:03:19,080 Right. 54 00:03:19,080 --> 00:03:20,910 I need to time end the day. 55 00:03:21,000 --> 00:03:26,520 So date time, very, very useful and used all the time in applications. 56 00:03:26,520 --> 00:03:33,750 And a really common use case in programming in general is when you have a column or let's say a row 57 00:03:33,750 --> 00:03:40,920 in a database and a table and it's created, you often want to just store the date and time it was created 58 00:03:41,310 --> 00:03:45,930 so that you can then go and sort things based off of how new they are and how old they are. 59 00:03:46,790 --> 00:03:51,920 It's very easy if you're working on comments, for example, going back to Facebook. 60 00:03:52,340 --> 00:03:56,420 Facebook comments are displayed in the order that they were written and posted. 61 00:03:56,420 --> 00:04:03,500 So you need to store that created at time so that to our date times come in and the format is also what 62 00:04:03,500 --> 00:04:10,370 you probably expect your year, year, year, dash, month, month dash de day, which is the date part 63 00:04:10,370 --> 00:04:11,480 and then a space. 64 00:04:11,570 --> 00:04:12,770 Our our colon. 65 00:04:12,770 --> 00:04:16,430 Minute, minute, colon, second, second, which is the time component. 66 00:04:17,779 --> 00:04:19,010 So we talked about those three. 67 00:04:19,010 --> 00:04:22,250 We didn't see them in action, but we saw that they exist. 68 00:04:22,250 --> 00:04:26,030 Date and time and date, time and again. 69 00:04:26,030 --> 00:04:27,410 I use date time the most. 70 00:04:27,410 --> 00:04:28,490 We'll be using it the most. 71 00:04:28,490 --> 00:04:31,130 It's the most versatile and the most useful.