Use the current_timestamp() function to return the current timestamp.
Optional Parameter
- time_zone
- Specifies the time zone to use for retrieving the current timestamp.Permitted values:
- "local": Uses the local time zone.
- Any valid time zone string.
Default value: "local"
Example 1: Assign the current timestamp in the local time zone to a DataFrame column
>>> from teradataml.dataframe.functions import current_timestamp
>>> load_example_data('dataframe', 'sales')
>>> df = DataFrame("sales")
>>> df.assign(current_timestamp = current_timestamp())
accounts Feb Jan Mar Apr datetime current_timestamp Alpha Co 210.0 200 215 250 04/01/2017 2025-05-27 17:36:56.750000+00:00 Blue Inc 90.0 50 95 101 04/01/2017 2025-05-27 17:36:56.750000+00:00 Jones LLC 200.0 150 140 180 04/01/2017 2025-05-27 17:36:56.750000+00:00 Orange Inc 210.0 None None 250 04/01/2017 2025-05-27 17:36:56.750000+00:00 Yellow Inc 90.0 None None None 04/01/2017 2025-05-27 17:36:56.750000+00:00 Red Inc 200.0 150 140 None 04/01/2017 2025-05-27 17:36:56.750000+00:00
Example 2: Assign the current timestamp in a specific time zone to a DataFrame column
>>> from teradataml.dataframe.functions import current_timestamp
>>> load_example_data('dataframe', 'sales')
>>> df = DataFrame("sales")
>>> df.assign(current_timestamp = current_timestamp("GMT+10"))
accounts Feb Jan Mar Apr datetime current_timestamp Blue Inc 90.0 50 95 101 04/01/2017 2025-05-28 03:39:00.790000+10:00 Red Inc 200.0 150 140 None 04/01/2017 2025-05-28 03:39:00.790000+10:00 Yellow Inc 90.0 None None None 04/01/2017 2025-05-28 03:39:00.790000+10:00 Jones LLC 200.0 150 140 180 04/01/2017 2025-05-28 03:39:00.790000+10:00 Orange Inc 210.0 None None 250 04/01/2017 2025-05-28 03:39:00.790000+10:00 Alpha Co 210.0 200 215 250 04/01/2017 2025-05-28 03:39:00.790000+10:00