Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 278
  • Last Modified:

get the time zone for databse instance

hi All,
i woould like to get the time zone for the datanase like us/pacific or us/easten or africa or europe some thing like that i need query to run into the database.(sql query)

pls dont give select dbtimezone from dual or SELECT SESSIONTIMEZONE FROM DUAl;

or SELECT * FROM v$timezone_names;

pls give the query which gives result like us/pacific some thing like that
0
nagavenuiluri
Asked:
nagavenuiluri
  • 5
1 Solution
 
OP_ZaharinCommented:
SELECT tzname FROM v$timezone_names
- will return you in us/pacific formatting. what are you looking for in specific?
0
 
OP_ZaharinCommented:
- this will return the us/pacific formatting based on your database timezone:

SELECT d.tzname FROM gv$timezone_names d
JOIN dual ON (EXTRACT(timezone_abbr FROM CURRENT_TIMESTAMP)) = d.tzabbrev
0
 
nagavenuiluriAuthor Commented:
no yar it is diaplying all the time zones what we have in that dictonary tables, i need the time zone in the format of us/pacific for my database only.

pls give me the solution.

0
Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
OP_ZaharinCommented:
- can you share the output of the following query when run on your database?

SELECT SYSTIMESTAMP, CURRENT_TIMESTAMP, DBTIMEZONE, SESSIONTIMEZONE FROM DUAL;
0
 
OP_ZaharinCommented:
1- since i have yet to receive any respond, lets do this test. the following query will return the datetime format with time zone information added:
SELECT * FROM NLS_SESSION_PARAMETERS where parameter = 'NLS_TIMESTAMP_TZ_FORMAT'
- it return:
PARAMETER | VALUE
=================================
NLS_TIMESTAMP_TZ_FORMAT | 'DD-MON-RR HH.MI.SSXFF AM TZR'


2- create a test table
CREATE TABLE test ( tz varchar2(25), newdate timestamp(6) WITH TIME ZONE);


3- insert a test data
INSERT INTO test select 'xx', localtimestamp FROM dual;


4- select the test table to see the timezone format
select to_char(newdate,'DD-MON-RR HH.MI.SSXFF AM TZR') as MYDATE, substr(newdate,-6,6) as TZ from test;      

MYDATE | TZ
=================================
11-MAY-11 04.45.27.138000 PM +08:00 | +08:00

- from the above result you know that the time zone is +08:00. to get the time zone name from this result however, i have yet to find any documentation that point to it. even the time zone database (v$timezone_names) only contain tz name and abbreviation. so no way to match this to the tz name.

0
 
OP_ZaharinCommented:
- to add: you can change the "localtimestamp" in step #3 to "systimestamp" to returns the current system date and time (including fractional seconds and time zone) for your database.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now