Oracle timezone conversion

I have a requirment in which the database server time is being changed to GMT but one of the database users needs to store its data in CST or CDT as the case may be depending on daylight savings .I am thinking of writing a function which returns depending on date value passed on to it whether it is CST or CDT (depending on the day of the year ) and thiS function would be called from a before insert trigger for the tables so that the date data being passed on GMT time is converted back to CST or CDT before storing and stored as such then .Is this the best approach ,does oracle have a system function for this ? NEW_TIME is the function that I am aware of for timezone conversion however it doesnt take into consideration if it is CST or CDT .Thanks

What is the datatype - date, timestamp, timestamp with timezone?
There are ways of converting the date which includes daylight savings time considerations;
SQL> select sessiontimezone from dual
SESSIONTIMEZONE
-08:00        
1 row selected.
SQL> create table t(ts timestamp)
Table created.
SQL> insert into t values(to_timestamp('01-jun-2007 12:00:00', 'dd-mon-yyyy hh24:mi:ss'))
1 row created.
SQL> insert into t values(to_timestamp('01-dec-2007 12:00:00', 'dd-mon-yyyy hh24:mi:ss'))
1 row created.
SQL> SELECT ts,
   ts AT TIME ZONE 'UTC' utz,
   ts AT TIME ZONE 'Canada/Central' ctz
FROM t
TS                         UTZ                               CTZ                             
2007-06-01 12:00:00,000000 2007-06-01 20:00:00,000000 +00:00 2007-06-01 15:00:00,000000 -05:00
2007-12-01 12:00:00,000000 2007-12-01 20:00:00,000000 +00:00 2007-12-01 14:00:00,000000 -06:00

Similar Messages

  • TZ database and oracle timezone conversions

    Hi There,
    I was wondering if oracle has any inbuilt functionality to convert;
    -- a given date in UTC
    -- to a given timezone
    -- considering the daylight savings
    -- which (was/is/will) observe(d) on the target timezone at the time of the given date?
    I have read oracle database uses TZ database, which means it should have access to all the historical timezone daylight saving variations on any given date in the past.
    http://www.twinsun.com/tz/tz-link.htm
    Is this possible? if so could anyone please given an example? I would like to create a function which takes a date in UTC and a target timezone and returns the date in target timezone considering the daylight saving which was observed during the input date.
    I have to use this in a web based application (APEX). The application is capable of fetching the browser local timezone, so we have the target timezone, but then we also needs to know the historical daylight savings observation date ranges to correctly convert the past date.
    Hope I am not confusing. Glad if anyone could throw some light hopefully with some examples.
    I use Oracle 11gR2
    Kind Regards
    Ligon

    What is the datatype - date, timestamp, timestamp with timezone?
    There are ways of converting the date which includes daylight savings time considerations;
    SQL> select sessiontimezone from dual
    SESSIONTIMEZONE
    -08:00        
    1 row selected.
    SQL> create table t(ts timestamp)
    Table created.
    SQL> insert into t values(to_timestamp('01-jun-2007 12:00:00', 'dd-mon-yyyy hh24:mi:ss'))
    1 row created.
    SQL> insert into t values(to_timestamp('01-dec-2007 12:00:00', 'dd-mon-yyyy hh24:mi:ss'))
    1 row created.
    SQL> SELECT ts,
       ts AT TIME ZONE 'UTC' utz,
       ts AT TIME ZONE 'Canada/Central' ctz
    FROM t
    TS                         UTZ                               CTZ                             
    2007-06-01 12:00:00,000000 2007-06-01 20:00:00,000000 +00:00 2007-06-01 15:00:00,000000 -05:00
    2007-12-01 12:00:00,000000 2007-12-01 20:00:00,000000 +00:00 2007-12-01 14:00:00,000000 -06:00

  • Urgent : Timezone conversion issue

    Hi,
    I am having an issue in timezone conversion.Im trying to convert a date type value to server timzone before insert into table. Im writing the conversion code in validateEntity(). Im using OANLSServices methods for conversion.Since i have to pass java.util.Date to this convertTimezone() as first parameter(date to be converted),im converting the reqd date which is in oracle Date type to java util Date type. Function is returing java.util.date type, which is again converted to oracle Date type. then im passing this value to the setMethod, ie., setJoiningDate(Date ) in my case.
    the code is compiled with 0 errors. But wen i run the page and after entering date value and click save button , its throwing some exception like "oracle.jbo.ValidationException: JBO-28200: Validation threshold limit reached. Invalid Entities still in cache"
    and in the debug console, this code in the validateEntity() is executed 10 times. First time it is converting the date time value to date only format, then same this is executed 9 more times. Can anyone help to resolve this issue? Its very urgent.
    Thanks
    Harsha

    Harsha,
    Use this code and try again...!
    oracle.jbo.domain.Date join = getJoiningDate();
    // to convert oracle Date to Java util Date
    java.sql.Date joinSql =(java.sql.Date)join.dateValue();
    java.util.Date jdateUtil =
    getOADBTransaction().getOANLSServices().convertTimezone(joinSql,
    getOADBTransaction().getOANLSServices().getUserTimeZoneCode(),
    getOADBTransaction().getOANLSServices().getServerTimeZoneCode());
    // to convert back to oracle Date
    java.sql.Date jdateSql = new java.sql.Date(jdateUtil.getTime());
    oracle.jbo.domain.Date jdate = new oracle.jbo.domain.Date(jdateSql);
    setJoiningDate(jdate);
    --Mukul                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Sybase ASE to Oracle 11g conversion

    Hi,
    Can anyone please look at the following Sybase ASE to Oracle 11g conversion - the top remarked code is the original Sybase version and the two UPDATE blocks below are hopefully doing the same task... What I need to know is if there is a more simple (less code change) way of doing the same task, either as a single UPDATE or preferably even more similar to the original Sybase code..?
    -- /* now apply allocations */
    -- update diary_items
    -- set id_user = ia.id_user ,
    -- tx_icon_user = 'urlcats:/user_grey.gif?method:getAllocationInfo'
    -- from diary_items di,
    -- item_allocation ia
    -- where di.id_diary_item = ia.id_object
    -- and ia.id_object_type = 'W'
    -- and ia.id_user != 'autocats'
    -- OK!
    -- ??? Need to check if second UPDATE which is the same as above is required again...
    /* now apply notes */
    UPDATE diary_items
    SET diary_items.tx_icon_user =
    ( SELECT 'urlcats:/user_grey.gif?method:getAllocationInfo'
    FROM item_allocation
    WHERE item_allocation.id_object = diary_items.id_diary_item )
    WHERE EXISTS
    ( SELECT item_allocation.id_object
    FROM item_allocation
    WHERE item_allocation.id_object = diary_items.id_diary_item
    AND item_allocation.id_object_type = 'W'
    AND item_allocation.id_user != 'autocats' )
    UPDATE diary_items
    SET diary_items.id_user =
    ( SELECT item_allocation.id_user
    FROM item_allocation
    WHERE item_allocation.id_object = diary_items.id_diary_item )
    WHERE EXISTS
    ( SELECT item_allocation.id_object
    FROM item_allocation
    WHERE item_allocation.id_object = diary_items.id_diary_item
    AND item_allocation.id_object_type = 'W'
    AND item_allocation.id_user != 'autocats' )
    Many thanks!!!
    Edited by: 881552 on 25-Aug-2011 04:39

    I managed to work it out in the end - here's the solution...
    /* now apply allocations */
    update diary_items
    set ( id_user,
    tx_icon_user ) =
    ( select ia.id_user,
    'urlcats:/user_grey.gif?method:getAllocationInfo'
    from diary_items di,
    item_allocation ia
    where di.id_diary_item = ia.id_object
    and ia.id_object_type = 'W'
    and ia.id_user != 'autocats'
    )

  • Oracle Assets Conversion Release 12

    Hello Experts,
    I am going to develop the conversion program for Oracle Assets Conversion for release 12. I am new to Fixed Assets concepts.
    Could any one guide me what are all the steps to be followed. I understand by studying the user guide that there are 5 different ways to perform this Oracle Assets conversion.
    1.Adjusted current earnings(ACE)information
    2.Budget Data
    3.Mass addtions of Assets
    4.Production Information which is typically related to depreciation. and
    5.Physical Inventory data.
    Since ,as of now I don't have any requirement from my client. They just said to have a process developed to import the data into oracle apps using Oracle asset conversion using SQL loader.
    Any Sample codings will be a great help for me.
    Thanks,
    Ravi.

    Hi;
    Please follow below(and reference) and see its helpful:
    Subject: Suggestions for Converting into the Group Asset Structure in 11i and/or R12
    https://metalink2.oracle.com/metalink/plsql/f?p=200:27:7590783145359143218::::p27_id,p27_show_header,p27_show_help:685244.993,1,1
    Subject: Data Conversion Of Source Lines into Oracle Assets Doc ID: 265835.1
    Regards
    Helios

  • IMS to Oracle 9i Conversion

    Has anyone attempted a IMS to Oracle 9i conversion? does anyone know of any tools?

    I would start with the Oracle Access Manager for IMS...
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Format issue after Oracle Reports conversion

    Hi all:
    I am an intermediate Oracle Reports user and am evaluating teh use of BI Publisher as a replacement. Since I have a large number of reports, some of which are fairly complex, I wish to take advantage of the conversion tool.
    The report in this issue has no user parameters. The Data Model is a "Data Template" type as generated from the conversion routine. The connection used was as the schema owner.
    I can View the report, but the formatting is completely wrong and the charts are no longer in the report.
    What do I need to do to fix this?
    Any help appreaciated,
    Gary

    Hi Gary
    The converter does not handle charts at the moment. You will need to re-create those in the template.
    Need a bit more info on 'the formatting is completely wrong' to be able to comment further.
    Regards
    Tim

  • OMWB schema prefix (MS SQL Server to Oracle database conversion)

    I made automatical conversion + some manual changes (pipelined functions) to migrate MS SQL 2000 database to Oracle 9i. Still one issue remains which requires lot of manual conversion : Names of the tables in views after automatic conversion doesn't contain schema prefix and it doesn't compile on destination database.
    My question is: Is there any way to add schema prefix to table names in views automatically during migration process ?

    Hi Marcin,
    See my post in the OMWB forum
    Thanks
    BArry

  • Oracle TimeZones and Daylight savings time

    Hi,
    I am working on converting a bunch of old data to a new system. I ran a couple of validation reports for the end user to verify, it seems the times were off. I am in the EST but it seems the times in the db were stored as UTC.
    So when you convert the time from UTC to EST you need to subtract 5 hours but when it is DST you only subtract 4.
    I need to know how to figure out if a time was entered in DST or EST and then I can use something like a decode to decide how much to subtract.
    DST Rules:
    Stone Age -- 2006 First Sunday in April ,Last Sunday in October
    2007 -- present DST Begins 2 a.m. (Second Sunday in March)      DST Ends 2 a.m. (First Sunday in November)
    Here is part of my select statment:
    to_date(to_char(asgn.start_date-5/24,'DD-MON-YYYY')) effective_from,
    I looked at Ask Tom and other sites but could not find a good working example that didn't have a hard coded date. Maybe it is not possible in a select statement.
    Thanks so much for any help you can provide !!!! :)

    >
    I need to know how to figure out if a time was entered in DST or EST
    This seemed to do it:
    >
    I don't see how it possibly can. A DATE datatype does not contain timezone. See the definition of what it contains in the SQL Language doc
    http://docs.oracle.com/cd/B28359_01/server.111/b28286/sql_elements001.htm#i54330
    >
    12
    DATE
    Valid date range from January 1, 4712 BC, to December 31, 9999 AD. The default format is determined explicitly by the NLS_DATE_FORMAT parameter or implicitly by the NLS_TERRITORY parameter. The size is fixed at 7 bytes. This datatype contains the datetime fields YEAR, MONTH, DAY, HOUR, MINUTE, and SECOND. It does not have fractional seconds or a time zone.
    >
    So that DATE value has NO way of knowing what the timezone of the process that entered it was.
    And depending on the meaning of that DATE column you don't even know for sure if the date value represents a date in that process's timezone. I can enter a date representing '01-Jan-2007' but that date doesn't necessarily mean it belongs to my timezone.

  • Migration of Oracle forms conversion?

    Hi All,
    I would like to know steps or procedures for migrating oracle forms using Jdeveloper and Apex.
    By using which toll i mean Jdeveloper or apex we can achieve the best results?
    Thanks,
    Anoo..

    Hi,
    But when i have tried a poc for oracle conversion forms, it is converting into separete pages? in that scenerio how can we combine or i mean how to integrate it?
    and the same time can we get steps for Jdeveloper also.
    Apart from these i would what others tools can we use for migarting.
    Thanks,
    Anoo..

  • Problem with Oracle Timezones

    Hi,
    I am getting some problems while using oracle time zones. The query I am using is as:
    select FROM_TZ(CAST(TO_DATE('10/2/2005 10:22:30','DD/MM/YYYY HH:MI:SS AM') AS TIMESTAMP), 'GMT') at time zone 'Europe/Kiev' AS New_Time from dual;
    It gives me error as :
    ORA-01882: timezone region %s not found
    I checked that v$timezone_names contains entry for Europe/Kiev.
    The query works fine for some values but not for all values from v$timezone_names.
    What can be the reason for this error? Do I need to do any other setting?
    Thanks in advance.

    Hi,
    Thanks Laurent,
    Actually the problem arises when I try to connect to a remote machine. I have Oracle client installed on a machine(SQL*Plus: Release 9.2.0.1.0 ) and with this client I am connecting to a remote machine which has database, client and server installed on it(SQL*Plus: Release 9.2.0.6.0).
    The query works fine when I execute it by logging to the remote machine directly, but fails when I connect to that machine through the Oracle client machine.
    All machines have HP-UX.
    What can be the reason for such behavior?
    Thanks in advance.

  • Access Query to Oracle Query conversion

    I am converting an Access database to Oracle 8.1.6.
    There are lot of reports in Access. HOw can I convert the Access
    query to Oracle equivalent query??? Is there any tool available
    for conversion???

    FYI,
    Microsoft Access is using ANSI SQL. And Oracle has introduced ANSI SQL from Oracle 9i so, it is also in 10g.
    Oracle 10g does not stop backward compatibilty so, It is depends on person. And I am not forcing you to migrate query from ACCESS to Oracle. I have simply answer the question which you have asked. Whether you want to perform efficiently or not it's your choice.
    But one thing is sure, ORACLE (9i or 10g) provides ANSI SQL and MS ACCESS is using ANSI sql so, this task is feasible. No doubt about it.

  • Oracle timezone support

    Hello All,
    We are using Oracle 10 g. the database follows European timezone and we operate from USA. I am working on timezone dependent code and facing issues with it, any guidance will be a great help.
    When I use the query:
    1. "select current_timestamp from dual" I get time displayed in US timezone.
    2. "select systimestamp from dual", I get time in European timezone.
    No issues with the results of any of the above query, but when I use
    A* select extract (*hour from current_timestamp*) from dual; I get Hour displayed as ( European time - 1 ).
    B* It always gives Hour for a weird timezone, even if I change the timezone for the session by using "alter session set time_zone = 'EST' "
    Can someone please throw some light on this ?

    get the info of the client time zone and compare it with the installed one.
    you can store all this info in a oracle table and can perform your desired action.

  • Informix SE 7.x -- Oracle 8i conversion

    We are currently attempting to convert an Informix SE 7.x
    database to Oracle 8i. Our plan was to use the scripts to first
    convert it to Oracle 7, and then use the conversion assistant
    that comes with 8i to convert the O.7 to O.8i. However, a hitch
    has ocurred as the scripts only seem to support Informix Online
    7.x. If anybody out there could offer a few pointers on how to
    modify the scripts to allow this (or can offer any other
    information, for that matter), it would be greatly appreciated.
    Cheers,
    Gerhard Kessell-Haak
    null

    Hi Gerhard,
    The 7.x scripts may be far removed from what you need. It depends
    on how much the Informix data dictionary has changed between the
    two versions.
    The scripts work by extracting the data dictionary definitions of
    exch schema object. They then perform some relatively simple
    migrations e.g. datatypes, and then generate schema creation
    scripts for Oracle.
    If you are thinking of writing scripts, I would suggest that you
    start with trying to extract tables first. This should be
    relatively straightfoward and give you a feel for extracting the
    rest of the objects.
    Regards
    John
    Gerhard Kessell-Haak (guest) wrote:
    : We are currently attempting to convert an Informix SE 7.x
    : database to Oracle 8i. Our plan was to use the scripts to
    first
    : convert it to Oracle 7, and then use the conversion assistant
    : that comes with 8i to convert the O.7 to O.8i. However, a
    hitch
    : has ocurred as the scripts only seem to support Informix Online
    : 7.x. If anybody out there could offer a few pointers on how to
    : modify the scripts to allow this (or can offer any other
    : information, for that matter), it would be greatly appreciated.
    : Cheers,
    : Gerhard Kessell-Haak
    Oracle Technology Network
    http://technet.oracle.com
    null

  • DB2 timestamp to oracle timestamp conversion

    Does any one know how to convert Db2 timestamp into oracle timestamp.
    From DB2 we are getting timestamp in this format (2000-03-06-16.02.19.074474) (26 bytes).
    I want to insert this into oracle thru owb into oracle table with column type timestamp.
    Does anyone know the procedure for this type of conversion
    Thanks in advance..

    Hi,
    Try a migration tool at www.ispirer.com/chyfo.html
    It provides you the fastest, the easiest and the most powerful way to migrate
    DB2 database into Oracle.
    It works in conjunction with Oracle SQL Loader. The tool creates text files (moving of LOBs are fully supported), generates
    CREATE TABLE scripts for Oracle and control files for SQL Loader.
    The tool has a lot of other features.
    Best regards, Dmitry.
    null

Maybe you are looking for

  • Help needed to find right settings on custom built PC tower

    Hey guys, this is my first ever post on here, so i dont know what to expect. Well just recently i decided to build my own PC tower, for a complete noob, id say i did a relatively good job, with this in mind i know nothing about building PC'S and matc

  • Scroll bar problem...please help !

    I have 2 blocks. The first is master with a SCROLLING BAR, and the other one is detail. I wanna do some validations when the scroll bar of the master is scrolled...and i tried the forms trigger, KEY-SCRDOWN, but in version 4.5 of forms is doesn't fir

  • Apple TV error 9

    Not sure if this is where I post this but: My Apple TV had a error on TV screen showing a USB cable. I could not do a restore with the remote. I purchased a mini USB cable, plugged the TV box into my Mac and did a restore with iTunes. Error 9. I got

  • I restored my old iPhone 4 - it asked for a password, none of my usual codes worked, and now it's in "disabled" mode.

    I bought the new iPhone 5 awhile back and just placed my iPhone 4 in a drawer. In trying to set it up to give to my Mom, the restored iPhone 4 wanted a password. I used all the passwords I usually use and nada. I can't connect to iTunes because my ne

  • Changing Exchange Rate Posting in General Settings

    Hi, Plesae I need your help concerning the exchange rate. i'm using SAP Business One 8.8 PL 15. In the display tab in Administration -> System Initialization -> General Settings, I chose "Indirect". However, many transactions (invoices) were done. I