| |
- current_date()
- DESCRIPTION:
Function returns the current date at the time when the request started.
If it is invoked more than once during the request, the same date is returned.
The date returned does not change during the duration of the request.
The value returned depends on the setting of the DBS Control flag TimeDateWZControl
as follows:
* If the TimeDateWZControl flag is enabled, function returns a date constructed
from the session time and session time zone.
* If the TimeDateWZControl flag is disabled, function returns a date constructed
from the time value local to the Vantage server and the session time
zone.
For more information, see "DBS Control (dbscontrol)" in Teradata Vantage™ - Database Utilities , B035-1102 .
PARAMETERS:
None.
ALTERNATE NAME:
curdate
EXAMPLES:
# Load the data to run the example.
>>> load_example_data("dataframe", "admissions_train")
>>>
# Create a DataFrame on 'admissions_train' table.
>>> admissions_train = DataFrame("admissions_train")
>>> admissions_train
masters gpa stats programming admitted
id
22 yes 3.46 Novice Beginner 0
36 no 3.00 Advanced Novice 0
15 yes 4.00 Advanced Advanced 1
38 yes 2.65 Advanced Beginner 1
5 no 3.44 Novice Novice 0
17 no 3.83 Advanced Advanced 1
34 yes 3.85 Advanced Beginner 0
13 no 4.00 Advanced Novice 1
26 yes 3.57 Advanced Advanced 1
19 yes 1.98 Advanced Advanced 0
>>>
# Import func from sqlalchemy to execute current_date() function.
>>> from sqlalchemy import func
# Create a sqlalchemy Function object.
>>> current_date_ = func.current_date()
>>>
# Pass the Function object as input to DataFrame.assign().
>>> df = admissions_train.assign(current_date_col=current_date_)
>>> print(df)
masters gpa stats programming admitted current_date_col
id
13 no 4.00 Advanced Novice 1 20/07/28
26 yes 3.57 Advanced Advanced 1 20/07/28
5 no 3.44 Novice Novice 0 20/07/28
19 yes 1.98 Advanced Advanced 0 20/07/28
15 yes 4.00 Advanced Advanced 1 20/07/28
40 yes 3.95 Novice Beginner 0 20/07/28
7 yes 2.33 Novice Novice 1 20/07/28
22 yes 3.46 Novice Beginner 0 20/07/28
36 no 3.00 Advanced Novice 0 20/07/28
38 yes 2.65 Advanced Beginner 1 20/07/28
>>>
# "curdate" can be used as an alternative function name.
>>> current_date_ = func.curdate()
>>>
# Pass the Function object as input to DataFrame.assign().
>>> df = admissions_train.assign(current_date_col=current_date_)
>>> print(df)
masters gpa stats programming admitted current_date_col
id
5 no 3.44 Novice Novice 0 20/07/28
7 yes 2.33 Novice Novice 1 20/07/28
22 yes 3.46 Novice Beginner 0 20/07/28
19 yes 1.98 Advanced Advanced 0 20/07/28
15 yes 4.00 Advanced Advanced 1 20/07/28
17 no 3.83 Advanced Advanced 1 20/07/28
34 yes 3.85 Advanced Beginner 0 20/07/28
13 no 4.00 Advanced Novice 1 20/07/28
36 no 3.00 Advanced Novice 0 20/07/28
40 yes 3.95 Novice Beginner 0 20/07/28
>>>
|