Reputation: 83
I created an easier to test post here: ORA-01847 day of month must be between 1 and last day of month - but data is OK Problem solution described there
It took me hours to search for a comparable issue in the web - finally i think only you out there can help me.
I send my Query to Oracle 11 via SQL developer.
You may ignore the complete subselect (its in pastebin) - i added a dump of each column to see details.
I got big Problems when comparing timestamps in where clause: here my basic sql without where clause in last line:
select prod,operating,fakeday,prod_origin,operating_origin,
dump(prod),dump(fakeday),dump(operating) from
(
http://pastebin.com/wqX7dJPA
) sub
-- works: where sub.operating < to_timestamp('20140101','YYYYMMDD')
-- works: where sub.fakeday < to_timestamp('20140101','YYYYMMDD')
-- works NOT: where sub.prod < to_timestamp('20140101','YYYYMMDD')
Result without where clause is:
'PROD'| 'OPERATING'| 'FAKEDAY'| 'PROD_ORIGIN'|'OPERATING_ORIGIN'|'DUMP(PROD)'| 'DUMP(FAKEDAY)'| 'DUMP(OPERATING)'
25.11.13 00:00:00,000000000|25.11.13 00:00:00,000000000|25.11.13 00:00:00,000000000|',20131125,'|'25.11.2013'| 'Typ=187 Len=20: 7,221,11,25,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0'|'Typ=187 Len=20: 7,221,11,25,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0'|'Typ=187 Len=20: 7,221,11,25,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0'
24.02.14 00:00:00,000000000|24.02.14 00:00:00,000000000|24.02.14 00:00:00,000000000|',20140224,'|'24.02.2014'| 'Typ=187 Len=20: 7,222,2,24,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0'|'Typ=187 Len=20: 7,222,2,24,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0'|'Typ=187 Len=20: 7,222,2,24,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0'
28.10.13 00:00:00,000000000|28.10.13 00:00:00,000000000|28.10.13 00:00:00,000000000|',20131028,'|'28.10.2013'| 'Typ=187 Len=20: 7,221,10,28,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0'|'Typ=187 Len=20: 7,221,10,28,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0'|'Typ=187 Len=20: 7,221,10,28,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0'
28.10.13 00:00:00,000000000|28.10.13 00:00:00,000000000|28.10.13 00:00:00,000000000|',20131028,'|'28.10.2013'| 'Typ=187 Len=20: 7,221,10,28,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0'|'Typ=187 Len=20: 7,221,10,28,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0'|'Typ=187 Len=20: 7,221,10,28,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0'
20.01.14 00:00:00,000000000|20.01.14 00:00:00,000000000|20.01.14 00:00:00,000000000|',20140120,'|'20.01.2014'| 'Typ=187 Len=20: 7,222,1,20,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0'|'Typ=187 Len=20: 7,222,1,20,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0'|'Typ=187 Len=20: 7,222,1,20,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0'
If i add the where clause in last line filtering on 'prod' i'll run into
ORA-01830: Datumsformatstruktur endet vor Umwandlung der gesamten Eingabezeichenfolge
01830. 00000 - "date format picture ends before converting entire input string"
*Cause:
*Action:
If i'm using the other column sub.operating or sub.fakeday i'll receive correct filtered resultlist.
where sub.operating < to_timestamp('20140101','YYYYMMDD')
another important information - i can call
select prod,operating,prod-operating,fakeday
and it will work -> shows a interval result for prod-operating
BUT
where prod - operating = INTERVAL '0' DAY;
will lead to:
ORA-01847: Tag des Monats muss zwischen 1 und letztem Tag des Monats liegen
01847. 00000 - "day of month must be between 1 and last day of month"
Please help - i don't have any idea.
Upvotes: 1
Views: 4770