1 00:00:00,410 --> 00:00:03,400 One of the most powerful things you can do with SQL 2 00:00:03,400 --> 00:00:05,840 is run queries based on today's date. 3 00:00:05,840 --> 00:00:10,660 For example, sales totals from the beginning of the current month to today or 4 00:00:10,660 --> 00:00:12,950 all users who've signed up on your site today. 5 00:00:14,060 --> 00:00:17,100 But, you don't have to manually type in the current date 6 00:00:17,100 --> 00:00:19,250 each time you create a query. 7 00:00:19,250 --> 00:00:22,860 You can get today's date using a SQL function. 8 00:00:22,860 --> 00:00:26,690 If you're running a query to get all of today's comments on a blog, or 9 00:00:26,690 --> 00:00:30,970 retrieving the cells in the last week, you'll need to use the date function. 10 00:00:32,180 --> 00:00:35,090 To get today's date from the date function, 11 00:00:35,090 --> 00:00:37,820 you can pass in the string of now. 12 00:00:37,820 --> 00:00:41,730 If today was the first of April 2020, we'd expect to see this. 13 00:00:43,760 --> 00:00:49,050 If today was December 20th, 2019, we'd expect to see this. 14 00:00:49,050 --> 00:00:51,210 Let's see this function in action. 15 00:00:52,510 --> 00:00:54,610 This shows today's date. 16 00:00:54,610 --> 00:00:58,220 We'll get different values because obviously, I'm recording this in the past. 17 00:00:58,220 --> 00:00:59,860 Hello, you futuristic person, you. 18 00:01:00,930 --> 00:01:06,310 Let's find all the orders that were placed today, but haven't been shipped yet. 19 00:01:06,310 --> 00:01:11,049 When we review the orders table, we see that is a status. 20 00:01:13,130 --> 00:01:19,020 Let's run a SQL query that will get all distinct statuses form the orders table. 21 00:01:20,280 --> 00:01:25,970 We have placed and shipped, so we can search for all orders that are placed. 22 00:01:33,034 --> 00:01:39,412 And then we want to search for ordered_on to equal the date now. 23 00:01:50,012 --> 00:01:53,289 We can get this list of orders to the fulfillment staff, 24 00:01:53,289 --> 00:01:55,530 so they can send out today's orders. 25 00:01:56,830 --> 00:01:59,600 Whether you're a developer or analyst creating dashboard for 26 00:01:59,600 --> 00:02:03,980 others to use, using the date function is incredibly useful. 27 00:02:03,980 --> 00:02:08,100 In the next video, we'll see how we can run queries that will be able to generate 28 00:02:08,100 --> 00:02:10,350 more interesting results. 29 00:02:10,350 --> 00:02:13,420 And be sure to check out the teacher's notes to see the syntax 30 00:02:13,420 --> 00:02:16,480 on how to get today's date in other versions of SQL.