Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Hi All,
I have a server application in C++ which communicates between application and database. My server application communicates with both oracle and SQL. Now i want to get the time zone of my oracle and SQL database. I am able to get the current time zone in SQL now i want to get the current time zone in oracle. Can anyone please help me to find the time zone in oracle.

Thanks in advance.
Posted
Comments
barneyman 7-May-14 23:20pm    
why on earth would you want to know the sql/oracle servers' timezone?

 
Share this answer
 
Comments
hari111r 7-May-14 8:52am    
Hi Thanks for replay. I gives me only offset. I want time zone name. Is there any way to get the time zone name.
Kornfeld Eliyahu Peter 7-May-14 8:58am    
Maybe this can help you http://docs.oracle.com/cd/B28359_01/server.111/b28286/functions052.htm#SQLRF00639
hari111r 7-May-14 9:26am    
I tried with EXTRACT(TIMEZONE_REGION) but in the link itself it says "The ambiguity arises because the time zone numerical offset is provided in the expression, and that numerical offset may map to more than one time zone region." Any other way to find it or any thing i am missing here.
Kornfeld Eliyahu Peter 7-May-14 9:32am    
Create a variable of type TIMESTAMP WITH [LOCAL] TIMEZONE. Convert your date to it using CAST, than run EXTRACT on it...

"If TIMEZONE_HOUR, TIMEZONE_MINUTE, TIMEZONE_ABBR, TIMEZONE_REGION, or TIMEZONE_OFFSET is requested, then expr must evaluate to an expression of data type TIMESTAMP WITH TIME ZONE or TIMESTAMP WITH LOCAL TIME ZONE."
Maciej Los 7-May-14 9:31am    
Is there any problem to convert time offset to date/time?<br><br>
I'm afraid, the function to get time zone name on Oracle server doesn't exists! Have a look: Detecting System Time Zone<br>
 <br>
Please, read my comment to the solution 1 by Kornfeld Eliyahu Peter.

I'm almost sure it's impossible to get time zone name in Oracle server, because it's not supported.
I believe you need to write custom function[^]. The basic idea is to get time offset and compare it with the list of time zones, than to return proper time zone name.

Have a look here:
A Time Zones[^]
Obtaining Time Zone Names[^]

Note: i don't have access to Oracle database/server, so i can be wrong.

BTW: It might be useful too: Converting Time Zones With the AT TIME ZONE Clause[^]
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900