Hi there. As you recall in our last video, we went over the basics of working with date and time strings. In this video, I want to continue our exploration of these topics by going over some concrete examples because I really do think that's the best way to learn these things. So after we explore these examples, you should be able to: Use the STRFTIME function, also known as the string format time function, compute the current date and use it to compare to the recorded date in your data, use the NOW function, and combine several date and time functions together to manipulate data in specific ways. Okay, so our first example is a really common one. You have a date of birth and you want to figure out the actual year and month or day this person is born. To do this, you can see that I've actually selected my birth date and you can see that the format this is in is in or date-time format. We have our year, month, day, hours, minutes, and seconds. Now for birthday, especially someone in customer information system, we usually don't know the hour, minute, or second that that person was born. Or a lot of times, these are even blank and we want to get rid of them because it doesn't provide any value to our analysis. To do this, I've created three new columns, one for the year they're born, one for the month, and one for the day. This is also really helpful when you want to flatten out your data. You may want to create some different dimensions, such as years or months, to group it and aggregate it by. This will be a really helpful in a scenario like that. To do this, you're going to use the string format time function. I'm going to declare the function, then I'm going to say the time string I want, and then I'm going to grab that from. My time string is that I want to select the year. I'm getting that from birthdate, and then I'm creating my alias to call it as year, so I remember what it was. And a similar thing happens for the month and the day. I'm just going to be using those different time strings to extract that. Here, you can see the results. Now that I've done is just take that one field and kind of flattened it over three, but having separate columns for my individual year, month, and date. Another common thing to do with date and time is to compute the current date. This is frequently used in analysis because you may want to look at something to see how many days it has been since a customer submitted an order. Maybe you're looking at it from today's perspective. So let's say, an order last happened five days ago and I need to know what the current date is so I can calculate how long ago that was. Another thing you may want to do is to compute the year, month, and day from the current date. This is just getting a little bit more specific. To do this, we can use one of the modifiers which is NOW. We're going to say, select the day and then NOW. If you just take that and write it into your system, you'll see it'll provide you the current date. I can also then compute the year, month, and day for the current date. Now, I'm combining my string format time function and also using the modifier of NOW to get the individual year, month, and day for the current date. Again, another example shows you how you can even get down to the hour, minute, second, and millisecond for that time. How frequently this is used though is again, going back to our example of the birthdate, a lot of times we really don't care about people's birthdate but we want to know their age. In this example, I took my previous query where I'm selecting the birthdate and I've separated out the year, the month, and the day. But I also added a new column where I'm going to select the age. What I did is, I took the current date, my date now, and then I minused it by the birthday. That return is age is the number. In this table below, you can see that I now have my original column birthdate. Then I have separated this data into these columns for the individual years, month, and day. And then finally, I have my new calculator column for the age. You can start to see how when you combine these functions together, you can really do a lot with dates. Dates are so essential in any analysis. A lot of times, you will really want to flatten out your data. So you're taking parts of that time stamp and computing maybe a second of time because you want to aggregate on that. For example, do we see a high volume of hits to our website at an individual second or is it over the span of a certain hour? So, being able to extract from a time stamp is so important to be able to do some of these types of analysis and aggregations, which is why we spend a good amount of time on how to manipulate dates and times in the last few lessons. We'll be moving on to another new and fun topic, though, in our next video.