| |
- current_time(fractional_precision)
- DESCRIPTION:
Function returns the current time when the request started.
If function is invoked more than once during the request, the same time is returned.
The time 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 time constructed
from the session time and session time zone.
* If the TimeDateWZControl flag is disabled, function returns a time constructed
from the time value local to the Vantage server and the session time
zone.
PARAMETERS:
fractional_precision:
Optional Argument.
Specifies a precision range for the returned value. The valid range
is 0 through 6. The default is 0.
NOTE:
Function accepts positional arguments only.
ALTERNATE NAME:
curtime
Note:
The function with this alternate name does not accept 'fractional_precision' value.
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_time() function.
>>> from sqlalchemy import func
# Create a sqlalchemy Function object.
>>> current_time_ = func.current_time()
>>>
# Pass the Function object as input to DataFrame.assign().
>>> df = admissions_train.assign(current_time_col=current_time_)
>>> print(df)
masters gpa stats programming admitted current_time_col
id
13 no 4.00 Advanced Novice 1 02:32:17+00:00
36 no 3.00 Advanced Novice 0 02:32:17+00:00
15 yes 4.00 Advanced Advanced 1 02:32:17+00:00
40 yes 3.95 Novice Beginner 0 02:32:17+00:00
22 yes 3.46 Novice Beginner 0 02:32:17+00:00
38 yes 2.65 Advanced Beginner 1 02:32:17+00:00
26 yes 3.57 Advanced Advanced 1 02:32:17+00:00
5 no 3.44 Novice Novice 0 02:32:17+00:00
7 yes 2.33 Novice Novice 1 02:32:17+00:00
19 yes 1.98 Advanced Advanced 0 02:32:17+00:00
>>>
# Get the current time with fractional precision value as 3.
>>> df = admissions_train.assign(current_time_col=func.current_time(3))
>>> print(df)
masters gpa stats programming admitted current_time_col
id
13 no 4.00 Advanced Novice 1 02:50:59.570+00:00
26 yes 3.57 Advanced Advanced 1 02:50:59.570+00:00
5 no 3.44 Novice Novice 0 02:50:59.570+00:00
19 yes 1.98 Advanced Advanced 0 02:50:59.570+00:00
15 yes 4.00 Advanced Advanced 1 02:50:59.570+00:00
40 yes 3.95 Novice Beginner 0 02:50:59.570+00:00
7 yes 2.33 Novice Novice 1 02:50:59.570+00:00
22 yes 3.46 Novice Beginner 0 02:50:59.570+00:00
36 no 3.00 Advanced Novice 0 02:50:59.570+00:00
38 yes 2.65 Advanced Beginner 1 02:50:59.570+00:00
>>>
# "curtime" can be used as an alternative function name.
>>> current_time_ = func.curtime()
>>>
# Pass the Function object as input to DataFrame.assign().
>>> df = admissions_train.assign(current_time_col=current_time_)
>>> print(df)
masters gpa stats programming admitted current_time_col
id
5 no 3.44 Novice Novice 0 02:32:47
34 yes 3.85 Advanced Beginner 0 02:32:47
13 no 4.00 Advanced Novice 1 02:32:47
40 yes 3.95 Novice Beginner 0 02:32:47
22 yes 3.46 Novice Beginner 0 02:32:47
19 yes 1.98 Advanced Advanced 0 02:32:47
36 no 3.00 Advanced Novice 0 02:32:47
15 yes 4.00 Advanced Advanced 1 02:32:47
7 yes 2.33 Novice Novice 1 02:32:47
17 no 3.83 Advanced Advanced 1 02:32:47
>>>
|