INVALID MONTH ERROR

I have seen a thread on this topic. But my issue is a bit different.
I have a table (suppose A) with a date column (let b B)
There is a view on this table say A_V. This view simply queries the table A.
I have another table C, to which I am inserting record from A_V in a for loop like
FOR i IN (SELECT * FROM A_V)
LOOP
INSERT INTO C(x,y,B)
VALUES( i.x,i.y,nvl(i.B,sysdate) );
END LOOP;
I found invalid month issue in it. I am not sure of the reason. However, do I need apply to_char on i.B or nvl(i.B,sysdate) to give it a specific format. And if so, how would I know what format I should apply.
I was also doing some test plsql developer and found result like this. Can anyone help me understand.
select id,nvl(to_char(DATE_DATA,'dd/MM/yyyy'),to_date('19000101','YYYYMMDD')) from DATA_DUMP
where DATE_DATA is null
result is
1 361725 01-JAN-00
2 800001 01-JAN-00
3 800002 01-JAN-00
4 420068 01-JAN-00
5 442682 01-JAN-00
6 442984 01-JAN-00
7 442340 01-JAN-00
select id,nvl(DATE_DATA,to_date('19000101','YYYYMMDD')) from DATA_DUMP
where DATE_DATA is null
1 361725 1/1/1900
2 800001 1/1/1900
3 800002 1/1/1900
4 420068 1/1/1900
5 442682 1/1/1900
6 442984 1/1/1900
7 442340 1/1/1900
I get similar result with DATA_DATA not null too.
-Deb

p.s. you also don't need to do your insert as single inserts within a cursor loop as this will give you poor performance. It should be done as a single insert... select... statement.
e.g.
SQL> select * from a;
     EMPNO     DEPTNO B
      7369         20 17/12/1980 00:00:00
      7499         30 20/02/1981 00:00:00
      7521         30 22/02/1981 00:00:00
      7566         20 02/04/1981 00:00:00
      7654         30 28/09/1981 00:00:00
      7698         30 01/05/1981 00:00:00
      7782         10 09/06/1981 00:00:00
      7788         20
      7839         10 17/11/1981 00:00:00
      7844         30 08/09/1981 00:00:00
      7876         20
      7900         30 03/12/1981 00:00:00
      7902         20 03/12/1981 00:00:00
      7934         10 23/01/1982 00:00:00
14 rows selected.
SQL> create table c (empno number, deptno number, b date);
Table created.
SQL> insert into c
  2  select empno, deptno, nvl(b,sysdate)
  3  from a;
14 rows created.
SQL> select * from c;
     EMPNO     DEPTNO B
      7369         20 17/12/1980 00:00:00
      7499         30 20/02/1981 00:00:00
      7521         30 22/02/1981 00:00:00
      7566         20 02/04/1981 00:00:00
      7654         30 28/09/1981 00:00:00
      7698         30 01/05/1981 00:00:00
      7782         10 09/06/1981 00:00:00
      7788         20 09/01/2009 15:24:04
      7839         10 17/11/1981 00:00:00
      7844         30 08/09/1981 00:00:00
      7876         20 09/01/2009 15:24:04
      7900         30 03/12/1981 00:00:00
      7902         20 03/12/1981 00:00:00
      7934         10 23/01/1982 00:00:00
14 rows selected.
SQL>

Similar Messages

  • Invalid month error sometimes in SQL Developer

    Hi
    sometimes I get 'Invalid Month error' in SQL developer when I execute the following query
    select TRUNC(TO_DATE('01-JUN-2013','DD-MON-YYYY')) from dual;
    But when I dosconnect session and reconnect, It works fine
    Any suggestions on how to avoid this issue ?
    Thanks

    872202 wrote:
    Hi
    sometimes I get 'Invalid Month error' in SQL developer when I execute the following query
    select TRUNC(TO_DATE('01-JUN-2013','DD-MON-YYYY')) from dual;
    But when I dosconnect session and reconnect, It works fine
    Any suggestions on how to avoid this issue ?
    ThanksThere's absolutely no reason that that should result in that error.
    The SQL is sent to the database and it's perfectly valid SQL, taking a string, and converting it to a date with the correct date format mask, and then truncating the date (which, by default is to the day, which in this case is pointless as it's already truncated), returning a DATE datatype, which SQL Developer will then render using it's date display format.

  • Strange invalid month error.

    Hi all,
    I have a function which receives a date and then returns a text string saying what day of the week it is, ie Monday Tuesday etc etc
    For example sakes I'll say the function is called dayoftheweek and we use the function like 'select somedate, dayoftheweek(somedate) from dual'
    Now, the bit within the function that works out the day is as below
    SELECT TO_CHAR(TO_DATE(p_date, 'DD/MM/RRRR') ,'DAY') from dual (p_date is the internal function variable for the date passed in.)
    Now, if I do this
    select dayoftheweek('25-MAY-09') from dual -- this works.
    But...
    select dayoftheweek('25/05/09') from dual -- this does not work, I get an ora 01843 invalid month error.
    So, I assumed it was something to do with the logic that worked out the day of the week.
    However, the below works.
    SELECT TO_CHAR(TO_DATE('25/05/09', 'DD/MM/RRRR') ,'DAY') from dual
    Does anyone know why when passing a date to the function in format 'select dayoftheweek('25/05/09') from dual' does not work but if I use this format within the function logic as above it does work?
    Cheers,
    rg

    Hello,
    Oracle does not know your date format:
    select dayoftheweek('25/05/09')I.e, it does not know that the date you are passing in is in the form of 'DD/MM/MM'. You must tell it (since it isn't your default format):
    select dayoftheweek(to_date('25/05/09', 'DD/MM/YY'))If all you wanted, however, was the day of the week from a date, then:
    TO_CHAR(to_date('25/05/09', 'DD/MM/YY'), 'DAY')Will give you that.
    And by the way, this:
    SELECT TO_CHAR(TO_DATE('25/05/09', 'DD/MM/RRRR') ,'DAY') from dualIs correct by chance, even though you're getting no error you may get the wrong result, because you're telling oracle you're passing in 4 digits for the year, yet you're only passing in two.
    Edit Beware:
    SQL> SELECT TO_CHAR(TO_DATE('25/05/09', 'DD/MM/RRRR'), 'YYYY') from dual;
    TO_C
    2009
    SQL> SELECT TO_CHAR(TO_DATE('25/05/09', 'DD/MM/YYYY'), 'YYYY') from dual;
    TO_C
    0009

  • Invalid month error in WEBI report level

    Hi,
    I had a issue with date format.I am using oracle10g as a backend database.I have a  date object in universe level i used that object in web intelligence report level.I created prompt for date object after select the date from the list i  am getting " invalid month error". In database level object datatype is timestamp.
    How to solve this issue.can somebody help me to solve the problem.

    Hi
    Date  Objects depends on various formats for different database
    Make sure that u format date like MM/dd/yyyy in universe level . and the object should be in date datatype .
    In the query level use prompt to select dates.
    In report level
    create a variable and use a formula like
    todate(userresponse("Enter date");"")
    Hope this helps U
    Sunil

  • Invalid Month error in PL/SQL

    Hi,
    The below query if given without the -- lines at an SQL prompt with work fine. But when used with in a PL/SQL will not work. It throws:
    sqlcode: -1843,sqlerrm: ORA-01843: not a valid month error.
    SELECT
    to_char(wk_beg_d,'dd/mm/yyyy'),to_char(wk_end_d,'dd/mm/yyyy')
    -- INTO
    -- v_fis_wk_strt_d,
    -- v_fis_wk_end_d
    FROM
    acct_date
    WHERE
    acct_d = '12-APR-07;
    Any suggestions will be very helpful.
    Thanks,
    Ravi.

    It reall depends on what you will be doing with v_fis_wk_strt_d and v_fis_wk_end_d.
    If you are just going to display them, and need to have that format for display purposes, then
    DECLARE
       v_fis_wk_strt_d VARCHAR2(11);
       v_fis_wk_end_d  VARCHAR2(11);
    BEGIN
       SELECT TO_CHAR(wk_beg_d,'dd/mm/yyyy'), TO_CHAR(wk_end_d,'dd/mm/yyyy')
       INTO v_fis_wk_strt_d, v_fis_wk_end_d
       FROM acct_date
       WHERE acct_d = TO_DATE('12-APR-2007', 'dd-mon-yyyy');
    END;If you are need to use them later as "real" dates, then, as Boneist suggested:
    DECLARE
       v_fis_wk_strt_d DATE;
       v_fis_wk_end_d  DATE;
    BEGIN
       SELECT wk_beg_d, wk_end_d
       INTO v_fis_wk_strt_d, v_fis_wk_end_d
       FROM acct_date
       WHERE acct_d = TO_DATE('12-APR-2007', 'dd-mon-yyyy');
    END;John

  • Invalid month error during import

    I have set NLS_DATE_FORMAT=”YYYY-MM-DD HH24:MI:SS’ in my import script, yet I get following error in import. I tried NLS_DATE_FORMAT=”RRRR-MM-DD HH24:MI:SS” as well, yet get same error. How can I get rid of the error.
    I am on Oracle 10.2.0.4 on HP UNIX.
    " ALTER TABLE "IN_ERM_SPOOL" MODIFY ("REPORT_TIME" DEFAULT '1970-01-01 00:00"
    ":00' )"
    IMP-00003: ORACLE error 1843 encountered
    ORA-01843: not a valid month
    IMP-00017: following statement failed with ORACLE error 1843:
    " ALTER TABLE "IN_EXTERN_MSG" MODIFY ("START_TIME" DEFAULT '1970-01-01 00:00"
    ":00' )"
    IMP-00003: ORACLE error 1843 encountered
    ORA-01843: not a valid month

    That was a typo. Double quotes are needed in shell script.I am sorry to see that COPY & PASTE is broken for you.
    Post results of
    SELECT * from v$version;
    I am NOT convinced that setting OS environmental variable has the desire results
    bcm@bcm-laptop:~$ export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'
    bcm@bcm-laptop:~$ sqlplus
    SQL*Plus: Release 11.2.0.1.0 Production on Sat Nov 20 19:52:55 2010
    Copyright (c) 1982, 2009, Oracle.  All rights reserved.
    Enter user-name: / as sysdba
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> select sysdate from dual;
    SYSDATE
    20-NOV-10
    SQL> alter session set NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS';
    Session altered.
    SQL> select sysdate from dual;
    SYSDATE
    2010-11-20 20:17:34
    SQL>

  • Invalid Month error in stored procedure

    Hello, I have a simple stored procedure that I pass a begin and end date into and it is complaining about the date formatting. Below is the table layout and stored procedure in question. How can I format the date for example as MM-DD-YYYY and not have it complain? I have tried using TO_DATE and TO_CHAR and it still complains.
    Thank you.
    -- Table
    CREATE TABLE INV_MOVE_ARCHIVE
    *( "RETAILER_ID" NUMBER NOT NULL,*
    *"SKU_ID" VARCHAR2(18 BYTE) NOT NULL,*
    *"OUTLET_ID" VARCHAR2(20 BYTE) NOT NULL,*
    *"QTY_CHANGE" NUMBER NOT NULL,*
    *"TRANS_DATE" DATE DEFAULT sysdate*
    -- Stored procedure
    CREATE OR REPLACE PROCEDURE inv_move_update(beginDate IN DATE, endDate IN DATE, retailerId IN INT)
    IS
    skuId VARCHAR(18);
    outletId VARCHAR(20);
    qtyChange INTEGER;
    -- Declaring the cursor
    CURSOR getInvRecord IS
    SELECT
    sku_id,
    outlet_id,
    qty_change
    INTO
    skuId,
    outletId,
    qtyChange
    FROM
    inv_move_archive
    WHERE
    retailer_id = retailerId AND
    trans_date >= beginDate AND
    trans_date <= endDate;
    BEGIN
    FOR rec_getInvRecord IN getInvRecord LOOP
    UPDATE OUTLET_SKU_XREF
    SET qty = qty + qtyChange
    WHERE outlet_id = outletId
    AND sku_id = skuId;
    COMMIT;
    END LOOP;
    EXCEPTION
    WHEN OTHERS THEN
    IF getInvRecord%isopen THEN CLOSE getInvRecord;
    END IF;
    END inv_move_update;
    */*

    Okay, I do not wantto change the table. I believe thatthe Java developers will need to change their code to call this procedure correctly. Another iss I am having is when I call this procedure manually from the database is is NOT doing the update. I put some debug statements in it and they indicate that the update statement is NOT updating any rows. If I run the select statement that is in the sp using the same parameters I pass into the sp it comes back with 1 row. The row to be updated is present in the table being updated.
    -- Here is my sp call
    DECLARE
      BEGINDATE DATE;
      ENDDATE DATE;
      RETAILERID NUMBER;
    BEGIN
      BEGINDATE := to_date('01/07/2009 00:00:00', 'MM/DD-YYYY HH24:MI:SS');
      ENDDATE := to_date('01/07/2009 11:59:59', 'MM/DD-YYYY HH24:MI:SS');
      RETAILERID := 104;
      INV_MOVE_UPDATE(
        BEGINDATE => BEGINDATE,
        ENDDATE => ENDDATE,
        RETAILERID => RETAILERID
    END;
    -- Select statement with same values
    SELECT
       sku_id,
       outlet_id,
       qty_change
    FROM
       inv_move_archive
    WHERE
       retailer_id = 104 AND
       trans_date >= to_date('01/07/2009 00:00:00', 'MM/DD-YYYY HH24:MI:SS') AND
       trans_date <= to_date('01/07/2009 11:59:59', 'MM/DD-YYYY HH24:MI:SS')
    -- Results from select
    036266579804040     9900165     500
    -- Here is the procedure with the debug statements in it.
    CREATE OR REPLACE PROCEDURE inv_move_update(beginDate IN DATE, endDate IN DATE, retailerId IN  INT)
    IS
            skuId VARCHAR(18);
            outletId VARCHAR(20);
            qtyChange NUMBER;
            errorMessage  VARCHAR(2500) := NULL;       
    -- Declaring the cursor
    CURSOR getInvRecord IS
          SELECT
             sku_id,
             outlet_id,
             qty_change
          INTO
             skuId,
             outletId,
             qtyChange
          FROM
             inv_move_archive
          WHERE
             retailer_id = retailerId AND
             trans_date >= beginDate AND
             trans_date <= endDate;
    BEGIN
       FOR rec_getInvRecord IN getInvRecord LOOP
          DBMS_OUTPUT.PUT_LINE('Rows Updated: ' || SQL%ROWCOUNT);
          UPDATE OUTLET_SKU_XREF
           SET qty = qty + qtyChange
          WHERE outlet_id = outletId
                AND sku_id = skuId;
          DBMS_OUTPUT.PUT_LINE('SKUID: ' || skuId);
          DBMS_OUTPUT.PUT_LINE('Rows Updated: ' || SQL%ROWCOUNT);
          COMMIT;       
       END LOOP;
    EXCEPTION
    WHEN OTHERS THEN
        errorMessage := 'Error updating the OUTLET_SKU_XREF table: ' || SQLCODE || ':' || SQLERRM;
        RAISE_APPLICATION_ERROR(-20001,errorMessage);
        DBMS_OUTPUT.PUT_LINE(errorMessage);
        IF getInvRecord%isopen THEN CLOSE getInvRecord;
        END IF;  
    END inv_move_update;
    /I get no errors when running it. The DBMS_OUTPUT shows null for the skuId and 0 for Rows Updated. Like I said I ran the select manually and it returns a row and I see that the row does exist in the target table. Any ideas what is going on here?
    Thank you
    -- David

  • Given query giving an error -invalid month????

    select to_date(add_months(trunc(sysdate),-5) ||' 10:30:00 AM','mm/dd/yyyy hh:mi:ss am') from dual
    giving an error-invalid month..

    1. Instead of comma you have put dot.
    2. Below is teh correct usage
    select to_date(to_char(add_months(trunc(sysdate),-5),'DD/MM/YYYY')||' 10:30:00 AM','DD/MM/YYYY HH:MI:SS AM')
    from dual3. But, why are you going for this when there is a straight forward way?

  • Case When Statement and ORA:01722 Invalid number error

    Hi folks, I have posted this under another heading as well under E-business suite so apologies if some you have already seen it but I would really appreciate some help on this one. Any suggestions are most welcome.
    We are trying to put together a calculation that returns the number of days absent an individual has had in a given time period. We need to cater for those absences that started before the period and are closed during it, absence that start during the period and end after it, and those that open and close within it.
    The period is always a rolling 6 months from sysdate.
    This is the calc we have come up with so far which works for some people but we get the invalid number error if the absence includes a half day - so 0.5, 1.5,etc.
    This is probably over complicated but we are not techie at all so are learning as we go!
    We are using the HRMS - Administration - Oracle Human Resources (Core) business area in 10G and the Absence Attendance and Person folders.
    SUM(TO_NUMBER(NVL(( CASE WHEN Absence Attendance.Actual Start Date < TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') THEN ( CASE WHEN Absence Attendance."Actual End Date" > SYSDATE THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),SYSDATE) ) ELSE ( CASE WHEN ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) END ) END ) END ) IS NULL THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),SYSDATE) ) ELSE ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) END ) END ) END ) END ) END ) ELSE ( CASE WHEN ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) END ) END ) END ) IS NULL THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),SYSDATE) ) ELSE ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( Absence Attendance.Duration Days ) END ) END ) END ) END ) END ),( DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") )),'999999990D00'))

    Hi,
    It could be that this is because you are using SYSDATE which contains the time as a fraction rather than TRUNC(SYSDATE) which just contains the current time. It could be that your working_dates_between raises this error.
    However, your formula is far more complicated than it needs to be.
    Firstly, you want to look at the date window ADD_MONTHS(TRUNC(SYSDATE), -6) to TRUNC(SYSDATE). Then you want to look at the portion of the absence that falls in the date window. This is GREATEST(Absence Attendance.Actual Start Date, ADD_MONTHS(TRUNC(SYSDATE), -6)) to LEAST(NVL(Absence Attendance."Actual End Date",TRUNC(SYSDATE)), TRUNC(SYSDATE)). You may need to add 1 to the absence end date because this is the last day of their absence rather than the date they return. It depends how you calculate the days between the start and end
    date of the absence. You can create calculations for the start and end date of the absences within the 6 months time window. Create calculation AbsenceStart as
    GREATEST(Absence Attendance.Actual Start Date, ADD_MONTHS(TRUNC(SYSDATE), -6))
    and AbsenceEnd as
    LEAST(NVL(Absence Attendance."Actual End Date",TRUNC(SYSDATE)), TRUNC(SYSDATE))
    Then you need to only pick up absence that a part of the absence in your 6 month date window. You can use a condition in the workbook or a condition in a case statement to do this. You then need to calculate the difference between these dates and SUM all the values.
    SUM(CASE WHEN AbsenceEnd >= AbsenceStart THEN WORKING_DAYS_BETWEEN(AbsenceStart, AbsenceEnd) END)
    That's it. Not so complicated after all.
    Rod West

  • Case When Statement and ORA:1722 Invalid number error

    Sorry I posted this in the wrong forum - I have the answer now
    Cheers
    HELP!!!
    We are trying to put together a calculation that returns the number of days absent an individual has had in a given time period. We need to cater for those absences that started before the period and are closed during it, absence that start during the period and end after it, and those that open and close within it.
    The period is always a rolling 6 months from sysdate.
    This is the calc we have come up with so far which works for some people but we get the invalid number error if the absence includes a half day - so 0.5, 1.5,etc.
    This is probably over complicated but we are not Techie at all so are learning as we go! We are using the HRMS - Administration - Oracle Human Resources (Core) business area in 10G and the Absence Attendance and Person folders.
    SUM(TO_NUMBER(NVL(( CASE WHEN Absence Attendance.Actual Start Date < TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') THEN ( CASE WHEN Absence Attendance."Actual End Date" > SYSDATE THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),SYSDATE) ) ELSE ( CASE WHEN ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) END ) END ) END ) IS NULL THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),SYSDATE) ) ELSE ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) END ) END ) END ) END ) END ) ELSE ( CASE WHEN ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) END ) END ) END ) IS NULL THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),SYSDATE) ) ELSE ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( Absence Attendance.Duration Days ) END ) END ) END ) END ) END ),( DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") )),'999999990D00'))
    Edited by: CPearce on Sep 25, 2008 8:03 AM

    Hi,
    It could be that this is because you are using SYSDATE which contains the time as a fraction rather than TRUNC(SYSDATE) which just contains the current time. It could be that your working_dates_between raises this error.
    However, your formula is far more complicated than it needs to be.
    Firstly, you want to look at the date window ADD_MONTHS(TRUNC(SYSDATE), -6) to TRUNC(SYSDATE). Then you want to look at the portion of the absence that falls in the date window. This is GREATEST(Absence Attendance.Actual Start Date, ADD_MONTHS(TRUNC(SYSDATE), -6)) to LEAST(NVL(Absence Attendance."Actual End Date",TRUNC(SYSDATE)), TRUNC(SYSDATE)). You may need to add 1 to the absence end date because this is the last day of their absence rather than the date they return. It depends how you calculate the days between the start and end
    date of the absence. You can create calculations for the start and end date of the absences within the 6 months time window. Create calculation AbsenceStart as
    GREATEST(Absence Attendance.Actual Start Date, ADD_MONTHS(TRUNC(SYSDATE), -6))
    and AbsenceEnd as
    LEAST(NVL(Absence Attendance."Actual End Date",TRUNC(SYSDATE)), TRUNC(SYSDATE))
    Then you need to only pick up absence that a part of the absence in your 6 month date window. You can use a condition in the workbook or a condition in a case statement to do this. You then need to calculate the difference between these dates and SUM all the values.
    SUM(CASE WHEN AbsenceEnd >= AbsenceStart THEN WORKING_DAYS_BETWEEN(AbsenceStart, AbsenceEnd) END)
    That's it. Not so complicated after all.
    Rod West

  • Why do I get a "DATE1 : ORA-00904 Invalid identifier" error ?

    Hi,
    Despite my efforts, I can't see why I get a "DATE1 : ORA-00904 Invalid identifier' error whith this request.
    {code}With S1 as (
    SELECT TRUNC(DATE1, 'MM'),
    ROUND(SUM(VALEUR), 2)
    FROM EVV_E036
    GROUP BY TRUNC(DATE1, 'MM')
    ORDER BY TRUNC(DATE1, 'MM'))
    SELECT n,
    NVL(ROUND(SUM(Valeur),2), 0)
    FROM (select add_months(to_date('01/01/2006', 'dd/mm/yyyy'), level - 1) n FROM dual connect by level <= 12) months
    LEFT JOIN S1
    ON months.n = TRUNC(DATE1, 'MM')
    GROUP BY n
    ORDER BY n{code}
    The line in error is this one : {code}ON months.n = TRUNC(DATE1, 'MM'){code}
    Any idea much appreciated !
    Regards,
    Christian

    hi,
    I have done this and get no more errors. Now I see that the values I get are equal to 0. Or, I do get values different from 0 in my table ! I can't see why the left join gives 0. I have to dig this and come back tomorrow.
    With S1 as (
    SELECT TRUNC(DATE1, 'MM') Date1,
           ROUND(SUM(VALEUR), 2) Debit
    FROM   EVV_E036
    WHERE  CLEF_VAR = (SELECT CLEF_VAR FROM SITE_ECHELLE WHERE SITE = 'E036')
    AND    DATE1 BETWEEN TO_DATE ('01/01/2007000000', 'DD/MM/YYYYHH24MISS') AND TO_DATE ('31/12/2007235959', 'DD/MM/YYYYHH24MISS')
    GROUP  BY TRUNC(DATE1, 'MM')
    ORDER  BY TRUNC(DATE1, 'MM'))
    SELECT n,
           NVL(ROUND(SUM(Debit),2), 0)
    FROM   (select add_months(to_date('01/01/2006', 'dd/mm/yyyy'), level - 1) n FROM dual connect by level <= 12) months
    LEFT JOIN S1
         ON months.n = date1
    GROUP BY n
    ORDER BY n

  • Invalid prompt Error in derived table

    hello All,
    I have the below query which works in SQL server...but the same query in derived table is giving invalid prompt error when instead of hardcoding the value...I gave  @prompt for user input value.
    SELECT
      convert(varchar(6), dateadd(MM,-3, convert(datetime, substring(cast(EMR_REPORTING.dbo.vMH_MEASURE_PRACTICE.RPT_YEAR_MONTH as varchar), 5,2) + '/' + '30' + '/'+ substring(cast(EMR_REPORTING.dbo.vMH_MEASURE_PRACTICE.RPT_YEAR_MONTH as varchar), 1,4))), 112) as prequarter,
      Primed_Status,
      EHR
    FROM
      EMR_REPORTING.dbo.vMH_MEASURE_PRACTICE
      where RPT_YEAR_MONTH = '201406'
    SELECT
      convert(varchar(6), dateadd(MM,-3, convert(datetime, substring(cast(EMR_REPORTING.dbo.vMH_MEASURE_PRACTICE.RPT_YEAR_MONTH as varchar), 5,2) + '/' + '30' + '/'+ substring(cast(EMR_REPORTING.dbo.vMH_MEASURE_PRACTICE.RPT_YEAR_MONTH as varchar), 1,4))), 112) as prequarter,
      Primed_Status,
      EHR
    FROM
      EMR_REPORTING.dbo.vMH_MEASURE_PRACTICE
      where RPT_YEAR_MONTH = @Prompt('Enter values for Rpt Year Month:','N','Folder\MeasurePractice\Rpt Year Month',Mono,Constrained)
    Thanks in advance for any inputs.
    Regards.

    Please check the Prompt definition and whether you are entering all the parameters in the prompt syntax.  As I could see there are only 5 parameters there in your prompt definitions

  • XML Parsing error: not well-formed (invalid token) (error code 4) --- Urgent Help Needed!

    Hi all, what im doing now is im trying to create a database connection my my MS SQL 2005 database. I created a data source and went to my Adobe Lifecycle Designer 7.1, i created a new data connection, selected OLEDB and created the connection string using the build function.
    Ok, now the problem is, after creating the new data connection and i click on the preview tab, i will receive the error stated above.
    'XML Parsing error: not well-formed (invalid token) (error code 4), line 444, column 1 of file'
    Does anyone know why am i receiving this error and how do i go about solving this?
    I need this database connection to pre-fill my form when the user downloads the form =(

    I have a vital form that clients fill out, which is passed to many people in the company along the workflow. The form is a Planner and we have in the following PDF, Word Doc..
    Well before, the Planner.pdf was originally created in Word, since most people have access to Word.. but evolved to a PDF form created from the Word Doc via Adobe LiveCycle Designer 8.0 w/ User Rights enabled so that the form could be filled out and saved using Adobe Reader.. which was a step better than Word.. being that it is free. But this needed to be easier and more to the point b/c some clients don't particularly like installing the latest version of Reader, even if you provide them the link. Nor do they like saving the form, filling the form, and attaching the form to send back.
    My goal is to have the client fill an HTML version of the form, submit and be done with it, but everyone in the workflow be able to easily receive the filled Planner as a PDF form.
    So some months ago I ran into this post Chris Trip, "Populate Livecycle PDF from mySQL database using PHP" #8, 22 Sep 2007 4:37 pm
    which uses the command line Win32 pdftk.exe to merge an FDF file into an existing PDF on the remote server, and serve this to whoever.
    My problem was with shared hosting and having the ability to use the Win32 pdftk.exe along with PHP which is predominantly used on Linux boxes. And we used a Linux box.
    so i created the following unorthodox method, which a client fills the HTML version of the Planner, all field values are INSERTED into a table in MySQL DB, I and all filled planners that have been filled by clients to date can be viewed from a repository page where an XML file is served up of the corresponding client, but someone would have to have Acrobat Professional, to import the form data from the XML file into a blank form.. altoughh this is simple for me.. I have the PHP file already created so that when a Planner is filled and client submits. >> the an email is sent to me with a table row from the repository of the client name, #, email, and a link to d-load the XML file,
    But I also have the PHP files created so that the Planner can be sent to by email to various people in the workflow with certain fileds ommitted they they do not need to see, but instead of the XML file beiong served up i need the filled PDF Planner to be served.
    I can do this locally with ease on a testing server, but I am currently trying to use another host that uses cross-platform compatibility so i can use PHP and the pdftk.exe to achieve this, as that is why I am having to serve up an XML file b/c we use a Linux server for our website, and cant execute the exe.
    Now that I am testing the other server (cross-platform host), just to use them to do the PDF handling (and it's only $5 per month) I am having problems with getting READ, WRITE, EXECUTE permissions..
    Si guess a good question to ask is can PHP do the same procedure as the pdftk.exe, and i can eleminate it.
    or how in the heck can i get this data from the DB into a blank PDF form, like i have described??
    here are some link to reference
    Populating a LiveCycle PDF with PHP and MySQL
    http://www.andrewheiss.com/Tutorials?page=LiveCycle_PDFs_and_MySQL
    HTML form that passed data into a PDF
    http://www.mactech.com/articles/mactech/Vol.20/20.11/FillOnlinePDFFormsUsingHTML/index.htm l
    and an example
    http://accesspdf.com/html_pdf_form/

  • HDD Invalid Sibling error, one hard drive has renamed itself with another harddrives name and now gives invalid Sibling error, what can i do?

    Hi
    So I have a few dozen hard drives for archiving and two of them have gone insane, The drives are named B1A and B6A. B1A is mounting and can be accessed however the desktop icon shows up as a faded yellow instead of the regular color and doesnt show in the finder sidebar.
    B6A is showing its partition as B1A (this is wrong) and not mounting at all. when repair is run it gives an invalid sibling error.
    What can i do, i've never heard about something like this.
    These two hard drives were used recently and worked fine could OSX somehow have mixed up HDD partition names on different drives
    Also these are mounted via USB, OSX 10.7.5

    Thank you Jim and Apple2Freak,
    I appreciate your comments. I am now suggesting to my friend to buy a legal OS and if that is the case I am suggesting to him to move to OSX instead of OS9. Luckily he let me know there wasn't much data on that drive that he needed to save. I am still trying to determine if I could still use this hard drive with the keylength errors if I erase it or if the hard drive has permanent damage. I am hoping that I could install OSX on it and erase the hard drive to start again.
    This imac (slot loading version) can support up to OS 10.3.9 however I might consider Xpostfacto to try to run 10.4. But then I would need to buy 10.3.9 as well as 10.4 and that would double my OS cost. I think I might just look for OS 10.3.9 only. Its not worth it for me to buy two OSes for it.
    Jim, your post was very interesting because it also pointed out that it could be an issue of bad RAM. A few months ago we installed some new second-hand RAM and I wonder if that is the cause of all these problems. I will have to check that first.
    Thanks again!

  • "invalid flavor error" Printing html docs

    DocFlavor flavor = DocFlavor.URL.TEXT_HTML_US_ASCII;
    I need to print a URL with an applet in Internet Explorer but keep getting the "invalid flavor" error.
    please post your answer in the following topic:
    http://forum.java.sun.com/thread.jsp?thread=350123&forum=57&message=2630553
    Thanks

    i tried to print all the flavors that my printer supports but i didn't understand the output.
    This is part of my code:
          DocFlavor[] flavors = service.getSupportedDocFlavors();
          for (int i = 0; i < flavors.length; i++) {
             cade1 += "\n" + flavors.toString();
          System.out.println(cade1);
          System.out.println("\n" + service.getName());This is the output of the app:
    [Ljavax.print.DocFlavor;@f62373
    [Ljavax.print.DocFlavor;@f62373
    [Ljavax.print.DocFlavor;@f62373
    [Ljavax.print.DocFlavor;@f62373
    [Ljavax.print.DocFlavor;@f62373
    [Ljavax.print.DocFlavor;@f62373
    [Ljavax.print.DocFlavor;@f62373
    [Ljavax.print.DocFlavor;@f62373
    [Ljavax.print.DocFlavor;@f62373
    [Ljavax.print.DocFlavor;@f62373
    [Ljavax.print.DocFlavor;@f62373
    [Ljavax.print.DocFlavor;@f62373
    [Ljavax.print.DocFlavor;@f62373
    [Ljavax.print.DocFlavor;@f62373
    \\data1\canonAny help?
    This is frustrating me quite a bit... I've been trying to print for months so far.
    Thanks,
    Silvio Sisto

Maybe you are looking for

  • Lumia 520 question

    Hi, i have to questions about operating the lumia 520: on the second screen where all the apps are listed , suddenly the apps are shown with the starting letter above them, how can i switch that off? when i fisrt started the phone the apps werent dev

  • How to hide the fields in the selection screen

    hi please let me know how to keep hide the fileds in the selection screen  i.e in display mode, for the condition

  • File permission​s issues

    Hi Guys, So I've noticed that at times on the flash and the SD cards, file permissions are getting changed somehow (inappropriately, i believe). Example, I download an MP3 file from the net.  file has read/write permissions.  a few days later the fil

  • Album Release Year (searched, didn't find anything)

    I've just recently noticed that the majority of the music from my iTunes library doesn't display anything for the Album Release Year field when in Front Row. I'd say maybe 2% of it is purchased from iTunes and those all display perfectly. The other 9

  • Where are my songs/playlists?

    I recently bought a Mac Air and had my old Mac Itunes, documents etc. transferred to my new Mac. I can't find my songs or playlists, just a "quick look" which plays a snippet. My account shows that I have purchased the songs. By fluke, I did find the