Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Julian Date error in SQL statement - but it has no Julian date

Julian Date error in SQL statement - but it has no Julian date

From: Tony van Lingen <tony.vanlingen_at_epa.qld.gov.au>
Date: Thu, 11 Jan 2007 13:06:51 +1000
Message-ID: <45A5A9CB.7080602@epa.qld.gov.au>


G'day,

I've just been alerted to a strange problem with a sql script that's been in use for years here. It contains the following statement:

SQL> l

  1  select to_char(hrs_start,'DD/MM, Day')                     day,
  2         round(Sum(nvl(hrs_end,sysdate)-hrs_start)*24,2)     hours
  3  FROM ACTIVITIES a,
  4       hours h,
  5       activity_persons p,
  6       personnel per
  7  WHERE a.JOB_ID = p.ACT_JOB_ID
  8    AND a.ID = p.ACT_ID
  9    AND h.ACT_ID = a.ID
 10    AND h.ACT_JOB_ID = a.JOB_ID

 11 AND h.PRS_CODE = p.PRS_CODE
 12 AND h.hrs_start >= to_date (nvl(:startdate, '1-1-1900') , 'DD-MM-YYYY' )
 13 AND h.hrs_end <= nvl(to_date( :enddate, 'DD-MM-YYYY' ), sysdate)  14 AND ((per.ORAUSER=user) AND (p.PRS_CODE=per.code))  15 GROUP BY to_char(hrs_start,'DD/MM, Day')  16* ORDER BY to_date ( to_char(hrs_start,'DD/MM, Day'), 'DD/MM, Day' )

It produces a nice sorted list of the hours worked on the various days in the given period (between :startdate and :enddate). The strange ORDER BY clause is necessary because of the GROUP BY on to_char(..). It's always worked nicely, for current dates as well as for previous years. This is the expected output:

SQL> exec :startdate := '1-1-2007';
SQL> exec :enddate := '31-1-2007';
SQL> /

DAY                   HOURS
---------------- ----------
02/01, Tuesday         9.53
03/01, Wednesday        9.9
04/01, Thursday        7.97
05/01, Friday          8.52
08/01, Monday          8.42
09/01, Tuesday         8.52
10/01, Wednesday       8.95
11/01, Thursday         .57

In the past year we migrated from 9.2x to 10.1.0.4 and the following errors now show up when we try and produce a list for any previous year:

SQL> exec :startdate := '1-12-2006';
SQL> /
GROUP BY to_char(hrs_start,'DD/MM, Day')

*

ERROR at line 15:
ORA-01835: day of week conflicts with Julian date

SQL> exec :enddate := '31-12-2006' ;
SQL> /
GROUP BY to_char(hrs_start,'DD/MM, Day')

*

ERROR at line 15:
ORA-01835: day of week conflicts with Julian date

And julian dates aren't even asked for! Has anyone seen this before? (Oracle DB 10.1.0.4.0 on Solaris, SQLPlus 10.1.0.4.0 on Windows & Linux)

-- 
Tony van Lingen



___________________________
Disclaimer

WARNING: This e-mail (including any attachments) has originated from a Queensland Government department and may contain information that is confidential, private, or covered by legal professional privilege, and may be protected by copyright.  

You may use this e-mail only if you are the person(s) it was intended to be sent to and if you use it in an authorised way.  No one is allowed to use, review, alter, transmit, disclose, distribute, print or copy this e-mail without appropriate authority.  If you have received this e-mail in error, please inform the sender immediately by phone or e-mail and delete this e-mail, including any copies, from your computer system network and destroy any hardcopies.

Unless otherwise stated, this e-mail represents the views of the sender and not the views of the Environmental Protection Agency.

Although this e-mail has been checked for the presence of computer viruses, the Environmental Protection Agency provides no warranty that all viruses have been detected and cleaned. Any use of this e-mail could harm your computer system.  It is your responsibility to ensure that this e-mail does not contain and is not affected by computer viruses, defects or interference by third parties or replication problems (including incompatibility with your computer system).

E-mails sent to and from the Environmental Protection Agency will be electronically stored, managed and may be audited, in accordance with the law and Queensland Government Information Standards (IS31, IS38, IS40, IS41 and IS42) to the extent they are consistent with the law.

___________________________

--
http://www.freelists.org/webpage/oracle-l
Received on Wed Jan 10 2007 - 21:06:51 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US