w3resource

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?



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/oracle-exercises/datetime/oracle-datetime-exercise-3.php