Home » SQL & PL/SQL » SQL & PL/SQL » Wierd Behaviour of dates with Time zone (oracle 11gR1)
- Wierd Behaviour of dates with Time zone [message #547042] Mon, 12 March 2012 00:57 Go to next message
srinivas.k2005
Messages: 404
Registered: August 2006
Senior Member
Hi,

select TO_DATE ( 
TO_CHAR ( 
FROM_TZ ( 
   CAST ( 
      TO_DATE ( 
	 '2012-03-11 02:59:42', 
	 'YYYY-MM-DD HH24:MI:SS') AS TIMESTAMP), 
   'CST6CDT') 
   AT TIME ZONE 'Europe/Dublin', 
'YYYY-MM-DD'), 
'YYYY-MM-DD') dt 
from dual;

Gives error:
ORA-01878: specified field not found in datetime or interval

If i change the date part time from 02:59:42 to 03:59:42, it works fine without issues:

select TO_DATE ( 
TO_CHAR ( 
FROM_TZ ( 
   CAST ( 
      TO_DATE ( 
	 '2012-03-11 02:59:42', 
	 'YYYY-MM-DD HH24:MI:SS') AS TIMESTAMP), 
   'CST6CDT') 
   AT TIME ZONE 'Europe/Dublin', 
'YYYY-MM-DD'), 
'YYYY-MM-DD') dt 
from dual;

Gives output:
DT
3/11/2012

If i chnage the Hour part from 02 to any other number it works fine



Please let me know any solutions

Thanks,SRK
- Re: Wierd Behaviour of dates with Time zone [message #547044 is a reply to message #547042] Mon, 12 March 2012 01:00 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>Please let me know any solutions
what is problem to be solved?
- Re: Wierd Behaviour of dates with Time zone [message #547046 is a reply to message #547044] Mon, 12 March 2012 01:03 Go to previous messageGo to next message
srinivas.k2005
Messages: 404
Registered: August 2006
Senior Member
The problem is when the hour part is 02:59:42 , it is throwing error
Gives error:
ORA-01878: specified field not found in datetime or interval

In a prod DB we have a date field stored with that timestamp and its failing with above error while executing the error
- Re: Wierd Behaviour of dates with Time zone [message #547048 is a reply to message #547046] Mon, 12 March 2012 01:07 Go to previous messageGo to next message
srinivas.k2005
Messages: 404
Registered: August 2006
Senior Member
Sorry missed to paste the below query...

select TO_DATE ( 
TO_CHAR ( 
FROM_TZ ( 
   CAST ( 
      TO_DATE ( 
	 '2012-03-11 03:59:42', 
	 'YYYY-MM-DD HH24:MI:SS') AS TIMESTAMP), 
   'CST6CDT') 
   AT TIME ZONE 'Europe/Dublin', 
'YYYY-MM-DD'), 
'YYYY-MM-DD') dt 
from dual;

Gives output:
DT
3/11/2012
- Re: Wierd Behaviour of dates with Time zone [message #547053 is a reply to message #547048] Mon, 12 March 2012 01:51 Go to previous messageGo to next message
Michel Cadot
Messages: 68758
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Quote:
The problem is when the hour part is 02:59:42 , it is throwing error
Gives error:
ORA-01878: specified field not found in datetime or interval


Because this datetime does not exist in the time zone you give and so it is not a valid one.
It is the expected behaviour.

Regards
Michel
- Re: Wierd Behaviour of dates with Time zone [message #581154 is a reply to message #547053] Tue, 02 April 2013 09:25 Go to previous messageGo to next message
amarnath123
Messages: 3
Registered: April 2013
Junior Member
Hi,
I am very new to oracle and db in general. I am getting this error too. I have a list of dates that are sent from my Java code to oracle 10g. I dont even know which date is causing this error. Any help is appreciated
- Re: Wierd Behaviour of dates with Time zone [message #581155 is a reply to message #581154] Tue, 02 April 2013 09:31 Go to previous messageGo to next message
cookiemonster
Messages: 13967
Registered: September 2008
Location: Rainy Manchester
Senior Member
Michels stated what causes the problem. So what else do you need from us?
- Re: Wierd Behaviour of dates with Time zone [message #581167 is a reply to message #581155] Tue, 02 April 2013 11:42 Go to previous messageGo to next message
amarnath123
Messages: 3
Registered: April 2013
Junior Member
Thats right. I have the following dates but I dont think any of them are invalid. Still why do I get this problem?2001-08-18-00.01.00.000000



2004-02-24-00.00.00.000000



2013-03-21-00.00.01.000000



2003-08-09-17.56.03.237578



2006-07-14-13.18.44.537542


1994-12-26-00.01.00.000000


2001-09-01-20.43.24.510203


2001-09-01-20.43.24.510203


2003-06-20-22.56.22.867129



2001-09-01-20.43.24.510203



2001-09-01-20.43.24.510203



2001-09-01-20.43.24.510203



2009-11-06-20.07.02.142375



2009-11-06-20.07.02.142375



2011-07-15-18.16.27.758236



2013-03-09-23.59.40.638272



2013-03-09-12.54.46.935842



2013-03-09-12.54.46.935842



2013-03-11-21.59.09.521464


2013-03-09-12.54.46.935842


2013-03-09-12.54.46.935842


2013-03-09-12.54.46.935842



2013-03-09-12.54.46.935842



2011-09-21-00.00.00.000001



2013-03-09-15.01.58.505517



2013-03-09-15.01.58.505517


2013-03-09-15.01.58.505517


2013-03-09-15.01.58.505517



2013-03-09-15.01.58.505517



2013-03-09-15.01.58.505517



2013-03-09-15.01.58.505517



2013-03-09-15.01.58.505517



2013-03-09-15.01.58.505517


2013-03-21-00.00.01.000000


2013-03-21-00.00.01.000000
- Re: Wierd Behaviour of dates with Time zone [message #581168 is a reply to message #581167] Tue, 02 April 2013 11:50 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Please read and follow the forum guidelines, to enable us to help you:

http://www.orafaq.com/forum/t/88153/0/


how can we reproduce what you report?
- Re: Wierd Behaviour of dates with Time zone [message #581169 is a reply to message #581168] Tue, 02 April 2013 11:55 Go to previous messageGo to next message
amarnath123
Messages: 3
Registered: April 2013
Junior Member
Hi I am using stored proc to insert the above dates into one of the tables. And while doing so I get the ora-01878 error. I thought it might be because of one of the dates and the DST problem. but the above list of dates are not in 2:00 -3:00 am on second sunday of March. So not sure why I get this error
- Re: Wierd Behaviour of dates with Time zone [message #581170 is a reply to message #581169] Tue, 02 April 2013 12:02 Go to previous messageGo to next message
Michel Cadot
Messages: 68758
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
So what do you expect from us?

Regards
Michel
- Re: Wierd Behaviour of dates with Time zone [message #581171 is a reply to message #581170] Tue, 02 April 2013 12:05 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>So not sure why I get this error
Neither are we.

Please read and follow the forum guidelines, to enable us to help you:

http://www.orafaq.com/forum/t/88153/0/


how can we reproduce what you report?
- Re: Wierd Behaviour of dates with Time zone [message #581175 is a reply to message #581171] Tue, 02 April 2013 13:45 Go to previous message
cookiemonster
Messages: 13967
Registered: September 2008
Location: Rainy Manchester
Senior Member
We don't have your code, we don't know what timezones you're using. So how do you expect us to know what the problem is?
Previous Topic: From with conditions
Next Topic: execute dynamic sql (2 Merged)
Goto Forum:
  


Current Time: Sat May 31 17:26:35 CDT 2025