Oracle: Current date in the specified session time zone
Oracle Datetime: Exercise-3 with Solution
Write a Oracle SQL statement to get the current date in the specified session time zone.
Sample Solution:
Oracle Code:
ALTER SESSION SET TIME_ZONE = '-8:0';
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';
SELECT SESSIONTIMEZONE, CURRENT_DATE FROM DUAL;
ALTER SESSION SET TIME_ZONE = '-9:0';
SELECT SESSIONTIMEZONE, CURRENT_DATE FROM DUAL;
Output:
SESSIONTIMEZONE CURRENT_DATE 1 -08:00 2/24/2021 3:31:46 AM SESSIONTIMEZONE CURRENT_DATE 1 -09:00 2/24/2021 2:31:46 AM
Improve this sample solution and post your code through Disqus.
Previous: Write a Oracle SQL statement to get the last date of the current month.
Next: Write a Oracle SQL statement to determine how many days are left in the current month.
What is the difficulty level of this exercise?
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics