Solved

create view - specify timezone for a date-type of column

Posted on 2014-04-09
5
438 Views
Last Modified: 2014-04-15
i have an oracle table-mytable1 with a column mydatecolumn1 - it is of the type - date
I want to create a view out of mytable1...

When i create the view, can i specify the timezone for mydatecolumn1, which specifies that all the date-time values of mydatecolumn1 are according to the timezone - USA Newyork Time or EST....

Please help

thanks so much
0
Comment
Question by:ts84zs
  • 3
  • 2
5 Comments
 
LVL 23

Expert Comment

by:David
ID: 39988819
My untried opinion is no, the view cannot add attributes to the source datatypes.  However, your view may be able to convert it with a function.  Let me read a little.
0
 

Author Comment

by:ts84zs
ID: 39988835
i can use sql-functions to specify convert(or do something with mydatecolumn1) mydatecolumn1  and specify timezone in that function

please help is there any such sql function ?

thansk so much
0
 
LVL 23

Accepted Solution

by:
David earned 500 total points
ID: 39988880
Have a look at:
"Switching Time Zones

The function new_time is used to convert a time to different time zones. To illustrate this we’ll look at entry 5 from the dates file.

SELECT entry, to_char(entry_date, 'MM/DD/YY HH:MI AM') FROM dates WHERE entry=5;

5 09/12/05 02:30 PM

This database is in US Eastern time but we want to display the time in US Central.

SELECT entry, to_char(new_time(entry_date, 'EST', 'CST'), 'MM/DD/YY HH:MI AM') FROM dates WHERE entry=5;

5 09/12/05 01:30 PM"

Read the source at: http://www.lifeaftercoffee.com/2005/09/22/converting-time-zones-in-oracle/

So, converting to EST -- how would you want to pass the original time zone into the function?  I presume it varies.
0
 

Author Comment

by:ts84zs
ID: 39988971
thanks so much where can i find timezone-values that goes in new_time(entry_date, 'EST', 'CST'),
like CST, PST, EST, UTC

I have to convert it to UTC timezone
0
 
LVL 23

Expert Comment

by:David
ID: 39989048
Addl:  to represent date then time with a T, see http://www.experts-exchange.com/Database/Oracle/Q_23024216.html.

Also see for the conversion: http://blog.watashii.com/2009/11/oracle-timezone-conversions-gmt-to-localtime/

SELECT CAST((FROM_TZ(CAST(TO_DATE('1999-12-01 22:00:00',
'YYYY-MM-DD HH24:MI:SS') AS TIMESTAMP), SESSIONTIMEZONE)
AT TIME ZONE 'GMT') AS DATE)
FROM DUAL;
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question