Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-04-09
5
Medium Priority
?
449 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

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.

Question has a verified solution.

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

How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
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 shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
Via a live example, show how to take different types of Oracle backups using RMAN.

721 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