Solved

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

Posted on 2014-04-09
5
426 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.

Join & Write a Comment

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
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.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

758 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now