This example illustrates how the
TODAY functions operate. Both functions generate outputs of Datetime data type.
NOW- Generates valid Datetime values for the current timestamp in the specified time zone. See NOW Function.
TODAY- Generates valid Datetime for the current date in the specified time zone. See TODAY Function.
DATEDIF- Calculates the difference between two Datetime values based on a specific unit of measure. See DATEDIF Function.
The following table includes flight arrival information for Los Angeles International airport.
You are interested in generating a status report on today's flights. To assist, you must generate columns with the current date and time values:
Tip: You should create separate columns containing static values for
TODAY functions. Avoid creating multiple instances of each function in your dataset, as the values calculated in them can vary at execution time.
Next, you want to identify the flights that are landing today. In this case, you can use the
DATEDIF function to determine if the
Arrival value matches the
currentTime value within one day:
DATEDIF function computes difference based on the difference from the first date to the second date based on the unit of measure. So, a timestamp that is 23 hours difference from the base timestamp can be within the same unit of day, even though the dates may be different (
Since you are focusing on today only, you can remove all of the rows that do not apply to today:
Now focusing on today's dates, you can calculate the difference between the current time and the arrival time by the minute:
Using the numeric values in the
status column, you can compose the following transform, which identifies status of each flight:
You now have a daily flight status report:
today columns can be deleted.
This page has no comments.