Use the current_date() function to return the current date based on the specified time zone.
Optional Parameter
- time_zone
- Specifies the time zone to use for retrieving the current date.Permitted values:
- "local": Uses the local time zone.
- Any valid time zone string.
Default value: "local"
Example 1: Add a new column to the DataFrame that contains the current date as its value
This example uses system-specified timezone as the timezone.
>>> from teradataml.dataframe.functions import current_date
>>> load_example_data('dataframe', 'sales')
>>> df = DataFrame("sales")
>>> df.assign(current_date=current_date())
accounts Feb Jan Mar Apr datetime current_date
Alpha Co 210.0 200.0 215 250 04/01/2017 25/05/27
Blue Inc 90.0 50 95 101 04/01/2017 25/05/27
Jones LLC 200.0 150 140 180 04/01/2017 25/05/27
Orange Inc 210.0 None None 250 04/01/2017 25/05/27
Yellow Inc 90.0 None None None 04/01/2017 25/05/27
Red Inc 200.0 150 140 None 04/01/2017 25/05/27
Example 2: Add a new column to the DataFrame that contains the current date in a specific time zone as its value
>>> from teradataml.dataframe.functions import current_date
>>> load_example_data('dataframe', 'sales')
>>> df = DataFrame("sales")
>>> df.assign(current_date=current_date("GMT"))
accounts Feb Jan Mar Apr datetime current_date
Alpha Co 210.0 200.0 215 250 04/01/2017 25/05/27
Blue Inc 90.0 50 95 101 04/01/2017 25/05/27
Jones LLC 200.0 150 140 180 04/01/2017 25/05/27
Orange Inc 210.0 None None 250 04/01/2017 25/05/27
Yellow Inc 90.0 None None None 04/01/2017 25/05/27
Red Inc 200.0 150 140 None 04/01/2017 25/05/27