1 00:00:00,390 --> 00:00:03,010 The powerful comparison operators we've been using 2 00:00:03,010 --> 00:00:05,330 can also be used with date types. 3 00:00:05,330 --> 00:00:07,430 Let's look at a couple of examples to see how they work. 4 00:00:08,490 --> 00:00:12,510 Let's take a look at our loans table and ask some real life questions. 5 00:00:12,510 --> 00:00:18,220 Let's find out what are all the loans that happened before December 13th, 2015? 6 00:00:18,220 --> 00:00:21,300 We can use a where clause. 7 00:00:21,300 --> 00:00:25,182 Remember, a where clause is column, operator, and value. 8 00:00:27,548 --> 00:00:30,748 The column to answer this question is loaned_on, 9 00:00:35,079 --> 00:00:40,220 And the value is 2015-12-13. 10 00:00:40,220 --> 00:00:42,960 Now, which operator do we use? 11 00:00:42,960 --> 00:00:45,080 Less than, or greater than? 12 00:00:45,080 --> 00:00:48,990 Since we're looking for dates before the value on the right hand side, 13 00:00:48,990 --> 00:00:51,570 we want to use the less than operator. 14 00:00:53,040 --> 00:00:58,110 All dates before a given date value are considered less than the value. 15 00:00:58,110 --> 00:01:02,580 All these results are the loans before December 13th, 2015. 16 00:01:02,580 --> 00:01:06,050 Okay, let's take a look at another question. 17 00:01:06,050 --> 00:01:09,076 Imagine today is December 18th, 2015. 18 00:01:09,076 --> 00:01:14,070 We want to send out a reminder to all those who have books due back soon. 19 00:01:14,070 --> 00:01:18,060 So the question would be which books are due back soon? 20 00:01:18,060 --> 00:01:22,010 Let's copy and paste this template here and fill in the condition. 21 00:01:23,390 --> 00:01:27,092 For the condition this time we want to use the return_by column. 22 00:01:31,254 --> 00:01:33,729 The value is 2015. 23 00:01:37,873 --> 00:01:40,021 -12-18. 24 00:01:42,340 --> 00:01:44,661 Since we wanted dates after a date value, 25 00:01:44,661 --> 00:01:47,259 we use the greater than operator in this case. 26 00:01:50,568 --> 00:01:51,910 Awesome. 27 00:01:51,910 --> 00:01:54,650 This query has returned all loans whether or 28 00:01:54,650 --> 00:01:58,030 not the books have already been returned to the library. 29 00:01:58,030 --> 00:02:02,830 A little later on I'll show you how to make this query return just the loans 30 00:02:02,830 --> 00:02:05,680 that haven't been returned to the library. 31 00:02:05,680 --> 00:02:08,705 Now we can find the patrons with the IDs of 1 or 3, 32 00:02:08,705 --> 00:02:11,821 send them an email reminder to return their books. 33 00:02:24,274 --> 00:02:29,070 We don't need to email patron 4 because they returned their books on the 17th.