Daylight Savings Time Confusion

Hello

I'm trying to understand how the Daylight Savings Time is handled in the Oracle database.
I read through the "Oracle Database globalization support Guide", especially this part to understand how it works.
However, I have some doubts about the way things work.
I'm particularly interested in how ambiguous date-time are managed.
I tried to find the reason to explain why same query returns different values when run through SQL and SQL Developer * more
Here are the details:
In SQL * Plus term
SQL> select * from v$version ;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE    11.2.0.2.0      Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production

SQL> select sessiontimezone, dbtimezone from dual ;

SESSIONTIMEZONE
---------------------------------------------------------------------------
DBTIME
------
+01:00
+00:00


SQL> select to_timestamp('31-MAR-2013 01:00:00','DD-MON-YYYY HH24:MI:SS') from dual ;

TO_TIMESTAMP('31-MAR-201301:00:00','DD-MON-YYYYHH24:MI:SS')
---------------------------------------------------------------------------
31-MAR-13 01.00.00.000000000

SQL> alter session set time_zone = 'Europe/London' ;

Session altered.

SQL> select to_timestamp('31-MAR-2013 01:00:00','DD-MON-YYYY HH24:MI:SS') from dual ;

TO_TIMESTAMP('31-MAR-201301:00:00','DD-MON-YYYYHH24:MI:SS')
---------------------------------------------------------------------------
31-MAR-13 01.00.00.000000000

SQL> select to_timestamp('31-MAR-2013 01:00:00','DD-MON-YYYY HH24:MI:SS') at time zone 'Europe/London' from dual ;
select to_timestamp('31-MAR-2013 01:00:00','DD-MON-YYYY HH24:MI:SS') at time zone 'Europe/London' from dual
                                                                     *
ERROR at line 1:
ORA-01878: specified field not found in datetime or interval
As you can see, when the clocks changed on the morning of March 31, there is no such thing as the time between 01:00 and 01:59:59 (as the clocks are put forward one hour at 01:00 to 02:00 AM). However, the TO_TIMESTAMP function returns the date that "invalid."
But when I run the same query (i.e. Select to_timestamp (March 31, 2013 01:00 "," DD-MON-YYYY HH24:MI:SS') of double) against the same database using SQL Developer, I get "02.00.00.000000000 March 31, 2013" as a result.
SESSIONTIMEZONE     DBTIMEZONE
Europe/London     +00:00
Can someone help me understand this behavior?

Thanks in advance.

Published by: user503699 on 19 April 2013 15:28

user503699 wrote:
I thought I could rephrase my original question here.
Is it possible using SQL (without JAVA) to generate the following results (e.g. in SQL)?

SELECT to_timestamp('30-MAR-2013 23:00:00','DD-MON-YYYY HH24:MI:SS') + NUMTODSINTERVAL(level*30, 'MINUTE') dt
FROM dual
CONNECT BY level <= 5 ;

DT
30-MAR-2013 11.30.00.000000000 PM
31-MAR-2013 12.00.00.000000000 AM
31-MAR-2013 12.30.00.000000000 AM
31-MAR-2013 02.00.00.000000000 AM
31-MAR-2013 02.30.00.000000000 AM

SQL * more, that seems to be what you need to get the desired result (or did you want to get the result exactly using the SQL code that you provided):

SQL> connect test_user/test

Connected.

SQL> alter session set time_zone = 'Europe/London';

Session altered.

SQL> select sessiontimezone, dbtimezone from dual;

SESSIONTIMEZONE                                                             DBTIME
--------------------------------------------------------------------------- ------
Europe/London                                                               +00:00

1 row selected.

SELECT
        cast (
                to_timestamp_tz('30-MAR-2013 23:00:00','DD-MON-YYYY HH24:MI:SS') + NUMTODSINTERVAL(level*30, 'MINUTE')
                as timestamp
        )dt
FROM dual
  7          CONNECT BY level <= 5
  8  ;

DT
---------------------------------------------------------------------------
30-MAR-13 11.30.00.000000 PM
31-MAR-13 12.00.00.000000 AM
31-MAR-13 12.30.00.000000 AM
31-MAR-13 02.00.00.000000 AM
31-MAR-13 02.30.00.000000 AM

5 rows selected.

Concerning
Jonathan Lewis

Tags: Database

Similar Questions

  • Daylight Savings time has elapsed - emails planned times changed?

    This weekend is over to Daylight Savings Time. I got an extra hour of sleep! Today, when I checked my campaigns in E10, I noticed that scheduled on all of my emails nurture has changed. This weekend, the planning time was Tuesday - Thursday between 10:00 and 15:00 central time. Today, the programming time is Tuesday - Thursday between 11:00 and 16:00 central time.

    Has anyone else has this problem? I was wondering if it was just me or if it happened to everyone as well.

    From what we can tell, Eloqua may adjust their servers for the time change, but this does not mean that they adjust the time periods applicable to your work. I work with them to adjust their schedules to be in harmony with our first direct go set up.

  • Problems of blackBerry Smartphones Daylight Savings Time calendar

    I've recently updated to BB Pearl and using the Desktop Manager Version 4.2.0.14.   I had installed the DST 2007 patch on PC for the old BB and had no problems in the past.  Now with the new BB all my appointment next week schedule are off by one hour on my BB.  It's havoc with my scheduling and synchronization with Outlook calendar.   Any ideas?

    Update - after a search through this forum has finally found a link for the 2007 DST Patch that had told me was not necessary for the Pearl.   Downloaded the patch and everything works fine now.

    http://www.BlackBerry.com/select/DST2007/resolutions/device_impact.shtml

  • Here's how to make a clock from Vista to Tripoli; and what happens if Tripoli had a unique rule for daylight saving time?

    Windows is a time zone for any city in Libya. I wanted a clock in Vista for Tripoli. The Libya isn't, daylight savings time, so I had to find a listed city which is GMT + 2, and also did not have the time. There is a pair, Harare (Zimbabwe) and Pretoria (South Africa). So I chose them for my clock.

    Now, if it happened that the Libya had a rule time advanced single - to say on April 15 and ending on September 9. No other GMT + 2 city would have this rule. So, what should I do? The only solution I could think of is to manually set the Tripoli to a non-heure GMT + 2 city when Tripoli was the light time of the day and for a non-heure GMT + 3 City when Tripoli was to DST. But is there a way to avoid these manual adjustments? Or would MS knows about the problem of Tripoli and added to the list?
    Thank you
    BTW, what is the appropriate category for this question?

    Hello Dick Moores,.

    There is no way to change the way it works on Vista. However, there are several third-party software that you can watch that will help you accomplish this. You can use your favorite search engine and look for the application that could help you do that.

    DISCLAIMER OF THIRD PARTY SOFTWARE:

    Using third-party software, including hardware drivers can cause serious problems that may prevent your computer from starting properly. Microsoft cannot guarantee that problems resulting from the use of third-party software can be solved. Software using third party is at your own risk.

    Thank you
    Irfan H, Engineer Support Microsoft Answers.

  • Daylights savings and time zone Arizona

    The clock will adjust for savings daylights for the time zone of the Arizona if the box adjust automatically activated?  Or check this get ignored as Arizona does not follow daylight saving time?

    Wednesday, May 16, 2012, 15:33:43 + 0000, Heather 12 wrote:

    The clock will adjust for savings daylights for the time zone of the Arizona if the box adjust automatically activated?  Or check this get ignored as Arizona does not follow daylight saving time?

    Neither. If you select the Arizona, the box to adjust for DST disappears.
    It is not a choice at all. It's the difference between the time of Arizona
    and mountain standard time.

    Ken Blake, Microsoft MVP

  • Time zone time/Daylight Savings conflict between Windows 7 and Illustrator CS6

    When summer time made its change this spring I started having problems saving files in Illustrator. I'm going to save the files, mainly the format .eps, and Illustrator, it blocks. I changed my time zone to an area that has not yet transformed because of DST, and it works. Unfortunately, I think a new time zone, also, he ends up hitting DST, and I'm at square one. I have searched once the Adobe site and the Windows site to find an answer to my problem, but am having no luck.

    My correct time zone

    (UTC-07:00) Mountain Time (US & Canada)

    I even tried to use Saskatchewan because they do not follow daylight saving time, but she also creates accidents. I tried several other time zones, the two worked so far are

    (UTC-06:00) Guadalajara, Mexico City, Monterrey (worked for a little while but a change in the weather a few weeks later messed up)

    (UTC) Casablanca (working on that area of time now), but an alert on my computer says that the changes in time to come the 28th

    Anyone know if there is a fix for this problem? I feel like I'm short on time, because I don't know how much more time zones will work.

    I finally found the solution! My account is configured as an administrator, but for some reason any Illustrator did not open with administrator permissions. I have to go to my menu start, right click on Illustrator and open as administrator. Suddenly, everything works more fast, more fluid and correctly! I do not understand the reason behind all this, but at least it's working correctly now.

  • Time zones and daylight saving time

    Hello

    Does anyone know how to handle DST on BI publisher?

    In the winter my system (MS - SQL database) records the dates as "2008-02 - 24 T 00: + 00:00 00:00.000" i.e. GMT; during the summer to account for daylight saving time, it records the date as "2008-04 - 04T 00: 00:00.000 + 01:00"-Note the + 01.00 at the end of British summer time / daylight saving time. (either way, the system records a date instead of a date and time).

    My problem is that the first will always return with February 24, 2008, while the second will come back with April 3, 2008 on the model and it does not seem be a switch or a code to take account of DST in the part Administration of BI or OPE / format masks.

    I'd rather have a solution for all of the BI, rather than an OPE solution so I can implement in the whole patch, but I'm open to suggestions.

    Thank you


    Richard

    Hi Richard,

    The only way I know is to use the following tag in your template:

    
    

    Kind regards

    Andy

  • Simple Q - What installation follow these Daylights savings?

    I have a new Sony's a6000 digital SLR and I put Date/time settings.  I know that the daylight saving time or DST, begins the second Sunday in March and ends on the first Sunday of November.  I'm in a geography which observes DST.  That is the question... If I set the DST yes / no setting to Yes, does that mean that I am in an area that observes DST so I want my camera to automatically adjust when the weather changes in March & November?

    (Someone told me it should be set to NO because we are not currently in DST but which is not intended for me since the camera 'knows' the date and should be able to understand this).

    If I understand correctly, the camera has only it on or off, so if you are currently in the DST like me, put on. When you're not in DST, change it out of service. The camera can't automatically.

    I did a quick test on my a55 (I know, it of an older camera, but think that Sony has kept the same programming) and unfortunately I had to manually change.

    I put it in my hometown, which currently has DST, then passed to another area which is not advanced, and left it on good and it has updated with the time, as if, as he has done, when it should not. My guess is, you need to set the DST on / off power manually.

    However, perhaps in newer devices it is corrected, you can try it.

    Canberra/Sydney/Melbourne is running DST. Viet Nam/Bangkok don't use DST.
    Lag at the present time is 4 hours, not in summer time, it's only 3. So try to adjust your time of Melbourne, DST, then move on to Bangkok. If there is a difference of 4 hours, automatically knows the a6000. If only 3, it's not.

    All the best

  • The Azerbaijan did not switch to daylight saving time this year. Please fix in Mac OS and iPhone

    Dear Apple,

    The Azerbaijan did not pass to DST at the end of March. Please correct the time zone in Mac OS and iPhone. Manually change the time on the two now!

    Thank you!

    You do not discuss Apple here. This is a forum for technical support to users, and we would have not any possibility to make changes. You can contact the Apple Support, or you can just provide the information to Apple using the feedback page. Go to http://www.apple.com/feedback and then click the area on the matter.

  • Sort of a disabling time zone / daylight saving time (DST)

    I have more than one year of data time-stamped in a file. The time stamp is GMT (UTC). When I have this graph, the graph allows to adjust the data for local time zone settings. I don't want it. I want to see UTC all the way through the data. The time is fed to the graph in the form of a table of the number of seconds. The graphic display of 'Absolute time' option is selected. It is the XY-graph function that implements the undesirable time zone + DST settings.

    I can compensate for the data for the time zone set on the local Windows system, but how to set the data so that when in graphic form, the graph does not create time in March and wasting time in October?

    Turn off the DST of Windows setting is not an option. The program that I write will be used on many machines around the world and I don't want the software to change the time zone settings are already on these machines. (Furthermore, I don't think the zone changes implemented are effective until a LV program restarts.) Or I want to ask users to do before using the program because it's just lame.

    There must be a way. Anyone know, please?

    Select the item that you want to reformat, go to properties, and go to "trainer". Select the advanced formatting and insert a ' ^' sign after the first<>

    See this online help on setting times in the form.

    This post on the forum is quite in detail on the subject.

    Tone

  • Iconia W3 win 8.1 end of advanced savings time bug?

    Someone else in the United States had problems with W3/Win 8.1 clock of the system today, the day time of ended in the United States (November 3, 2013)?  The clock on my tablet is an hour before now, even though my PC settings are set to automatically change the time.

    Thank you.

    Mine did not change until what I told it to synchronize with the time Internet. OTOH my 8.1 office has spent a lot of time to do something at the start but came to the top with the exact time.

  • Clock for Sydney, Australia suggest wrongly that daylight saving time begins at the end of October

    How can they be corrected?

    Make sure you have the time zone updates installed.

    http://support.Microsoft.com/kb/2570791

  • How to detect if daylight saving time is in effect

    Hello

    Is there a way to detect if DST is in effect?

    Ok

    I'm going on it again. I think I have a solution. Suppose you are in a place which observes DST. In other words, changes to the time of one hour for a period of one year.

    The code below is an example of what I did. It compares the time of noon for today and for the last day of December, in time UTC. If DST is activated, two dates will have a difference at the time. If this is not the case, the two hours will be equal.

    QDateTime now = QDateTime::currentDateTime();
    QDateTime nowTime(QDate(now.date().year(), now.date().month(), now.date().day()), QTime(12, 0));
    QDateTime xmas(QDate(now.date().year(), 12, 31), QTime(12, 0));
    
    QDateTime n2=nowTime.toUTC();
    QDateTime x2=xmas.toUTC();
    
    int time1 = n2.time().hour();
    int time2 = x2.time().hour();
    
    if (time1 == time2)
        qDebug() << "DST not in effect.";
    else
        qDebug() << "DST in effect.";
    
  • Treo 800 W - Daylight Saving Time

    My Treo 800W switched time correctly during summer time. However on the last few days, it keeps jumping to another time. I continue to go back to the settings and change the time. I even put it back an hour while when I woke up this morning he read the exact time. 2 hours later, however, he jumped forward again? If I change times zones, it will change the time in my Appointment book. Sprint Customer service sadi to take a Sprint Store to support. Any ideas?

    Check the time zone and the time on the PC and make sure that both are correct. If they check them on the device. Most likely the problem is with the PC zone off by one.

    Message is about: Treo 800w (Sprint)

  • Convert unix timestamp to date after the change to daylight saving time

    Hello

    in one of the products, we use internal Scheduler stores dates (and times) in a format Unix, which is seconds since January 1, 1970. We used this SQL to extract the effective date:

    To_char (t.next_fire_time /(24*60*60*1000) + to_date('19700101020000','yyyymmddhh24miss'), 'yyyymmddhh24miss')

    Everything worked well until that time has changed this weekend from UTC + 2 to UTC + 1 (we are located in Eastern Europe). Since then, the above query returns an hour later than planned.

    I.e. of timestamp * 1320067800000 * is returned as * 20111031153000 * even thought is correct (and the actual time, the event was planned) * October 31, 11 PM 02.30.16.000000 *.

    I found queries like this on various forums and nobody seems to care of DST. Is this a configuration problem in the DB or is this a bug in our code?

    I tried selecting the SESSIONTIMEZONE and the DBTIMEZONE and both were + 1.

    Any help appreciated.

    Your problem is coded hard 2 hours shift:

    TO_DATE (19700101'020000', 'yyyymmddhh24miss')

    You need to calculate the current offset to adapt it to the current situation of DST:

    with sample_table as (
                          select date '1970-01-01' + 1320067800000 / 1000 / 3600 / 24 dt_utc from dual
                         )
    select  dt_utc,
            dt_utc +
            extract(
                         timezone_hour
                    from
                         from_tz(cast(dt_utc as timestamp),'utc') at time zone 'Europe/Prague'
                   ) / 24 dt_prague,
            extract(
                         timezone_hour
                    from
                         from_tz(cast(dt_utc as timestamp),'utc') at time zone 'Europe/Prague'
                   ) tz_offset
      from  sample_table
    /
    
    DT_UTC              DT_PRAGUE            TZ_OFFSET
    ------------------- ------------------- ----------
    2011-10-31 13:30:00 2011-10-31 14:30:00          1
    
    SQL> 
    

    SY.

Maybe you are looking for