Oracle LOCALTIMESTAMP function
How to get current date and time values in the current session in Oracle?
The LOCALTIMESTAMP() function returns the current date and time in the session time zone in a value of datatype TIMESTAMP.
Syntax:
LOCALTIMESTAMP [ (timestamp_precision) ]
Parameters
Name | Description |
---|---|
timestamp_precision (optional) | Specifies the fractional second precision of the time value returned. |
Note: LOCALTIMESTAMP returns a TIMESTAMP value while CURRENT_TIMESTAMP returns a TIMESTAMP WITH TIME ZONE value.
Pictorial Presentation
Examples: Oracle LOCALTIMESTAMP () function
The following statements shows the difference between LOCALTIMESTAMP and CURRENT_TIMESTAMP:
SQL> ALTER SESSION SET TIME_ZONE = '-2:00';
Session altered.
SQL> SELECT CURRENT_TIMESTAMP, LOCALTIMESTAMP FROM DUAL;
Sample Output:
CURRENT_TIMESTAMP LOCALTIMESTAMP --------------------------------------------------------------------------- 01-MAY-15 05.32.24.211000 AM -02:00 01-MAY-15 05.32.24.211000 AM
SQL> ALTER SESSION SET TIME_ZONE = '-5:00';
Session altered.
SQL> SELECT CURRENT_TIMESTAMP, LOCALTIMESTAMP FROM DUAL;
Sample Output:
CURRENT_TIMESTAMP LOCALTIMESTAMP --------------------------------------------------------------------------- 01-MAY-15 02.32.46.226000 AM -05:00 01-MAY-15 02.32.46.226000 AM
Previous:
LAST_DAY
Next:
MONTHS_BETWEEN
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework