title: ora-01861 literal does not match format string
body: <pre><code>select contract.contract_id
  from swcd.scd_contract contract 
  
  left join SCD.COMPANY_TIMELINE_VIEW customer on (customer.company_id=contract.customer_company_id and to_char(to_date(case when contract.ANNOUNCEMENT_DATE is null then case when contract.ANNOUNCEMENT_QUARTER='Q1' then '1-JAN-' when contract.ANNOUNCEMENT_QUARTER='Q2' then '1-APR-'
  when contract.ANNOUNCEMENT_QUARTER='Q3' then '1-JUL-' when contract.ANNOUNCEMENT_QUARTER='Q4' then '1-OCT-' end || contract.ANNOUNCEMENT_YEAR else to_char(contract.ANNOUNCEMENT_DATE) end),'dd-MON-YYYY') &gt;= (CASE WHEN customer.EVENT_START_DATE is null THEN to_date('01-JAN-1901', 'DD-Mon-YYYY') else 
  trunc(customer.EVENT_START_DATE) END) AND to_char(to_date(case when contract.ANNOUNCEMENT_DATE is null then case when contract.ANNOUNCEMENT_QUARTER='Q1' then '1-JAN-' when contract.ANNOUNCEMENT_QUARTER='Q2' then '1-APR-'
  when contract.ANNOUNCEMENT_QUARTER='Q3' then '1-JUL-' when contract.ANNOUNCEMENT_QUARTER='Q4' then '1-OCT-' end || contract.ANNOUNCEMENT_YEAR else to_char(contract.ANNOUNCEMENT_DATE) end),'dd-MON-YYYY') &lt;= (CASE WHEN customer.EVENT_END_DATE is null THEN to_date('01-JAN-2101', 'DD-Mon-YYYY') else 
  trunc(customer.EVENT_END_DATE) END)) 
  
  left join SCD.COMPANY_TIMELINE_VIEW vendor on (vendor.company_id=contract.vendor_company_id and to_char(to_date(case when contract.ANNOUNCEMENT_DATE is null then case when contract.ANNOUNCEMENT_QUARTER='Q1' then '1-JAN-' when contract.ANNOUNCEMENT_QUARTER='Q2' then '1-APR-'
  when contract.ANNOUNCEMENT_QUARTER='Q3' then '1-JUL-' when contract.ANNOUNCEMENT_QUARTER='Q4' then '1-OCT-' end || contract.ANNOUNCEMENT_YEAR else to_char(contract.ANNOUNCEMENT_DATE) end),'dd-MON-YYYY') &gt;= (CASE WHEN vendor.EVENT_START_DATE is null THEN to_date('01-JAN-1901', 'DD-Mon-YYYY') else
  trunc(vendor.EVENT_START_DATE) END) AND to_char(to_date(case when contract.ANNOUNCEMENT_DATE is null then case when contract.ANNOUNCEMENT_QUARTER='Q1' then '1-JAN-' when contract.ANNOUNCEMENT_QUARTER='Q2' then '1-APR-'
  when contract.ANNOUNCEMENT_QUARTER='Q3' then '1-JUL-' when contract.ANNOUNCEMENT_QUARTER='Q4' then '1-OCT-' end || contract.ANNOUNCEMENT_YEAR else to_char(contract.ANNOUNCEMENT_DATE) end),'dd-MON-YYYY') &lt;= (CASE WHEN vendor.EVENT_END_DATE is null THEN to_date('01-JAN-2101', 'DD-Mon-YYYY') else 
  trunc(vendor.EVENT_END_DATE) END));
  </code></pre>
  
  <p>This is my query I am executing on Oracle 10g. This shows a strange behavior to me.
  When I execute the <code>select</code> query with either of join it works fine, But with both the required joins it says <code>ora-01861 literal does not match format string</code>.</p>
  
  <pre><code>-- Works fine
  select contract.contract_id
  from swcd.scd_contract contract 
  
  left join SCD.COMPANY_TIMELINE_VIEW customer on (customer.company_id=contract.customer_company_id and to_char(to_date(case when contract.ANNOUNCEMENT_DATE is null then case when contract.ANNOUNCEMENT_QUARTER='Q1' then '1-JAN-' when contract.ANNOUNCEMENT_QUARTER='Q2' then '1-APR-'
  when contract.ANNOUNCEMENT_QUARTER='Q3' then '1-JUL-' when contract.ANNOUNCEMENT_QUARTER='Q4' then '1-OCT-' end || contract.ANNOUNCEMENT_YEAR else to_char(contract.ANNOUNCEMENT_DATE) end),'dd-MON-YYYY') &gt;= (CASE WHEN customer.EVENT_START_DATE is null THEN to_date('01-JAN-1901', 'DD-Mon-YYYY') else 
  trunc(customer.EVENT_START_DATE) END) AND to_char(to_date(case when contract.ANNOUNCEMENT_DATE is null then case when contract.ANNOUNCEMENT_QUARTER='Q1' then '1-JAN-' when contract.ANNOUNCEMENT_QUARTER='Q2' then '1-APR-'
  when contract.ANNOUNCEMENT_QUARTER='Q3' then '1-JUL-' when contract.ANNOUNCEMENT_QUARTER='Q4' then '1-OCT-' end || contract.ANNOUNCEMENT_YEAR else to_char(contract.ANNOUNCEMENT_DATE) end),'dd-MON-YYYY') &lt;= (CASE WHEN customer.EVENT_END_DATE is null THEN to_date('01-JAN-2101', 'DD-Mon-YYYY') else 
  trunc(customer.EVENT_END_DATE) END));
  
  -- Works fine
  select contract.contract_id
  from swcd.scd_contract contract 
  left join SCD.COMPANY_TIMELINE_VIEW vendor on (vendor.company_id=contract.vendor_company_id and to_char(to_date(case when contract.ANNOUNCEMENT_DATE is null then case when contract.ANNOUNCEMENT_QUARTER='Q1' then '1-JAN-' when contract.ANNOUNCEMENT_QUARTER='Q2' then '1-APR-'
  when contract.ANNOUNCEMENT_QUARTER='Q3' then '1-JUL-' when contract.ANNOUNCEMENT_QUARTER='Q4' then '1-OCT-' end || contract.ANNOUNCEMENT_YEAR else to_char(contract.ANNOUNCEMENT_DATE) end),'dd-MON-YYYY') &gt;= (CASE WHEN vendor.EVENT_START_DATE is null THEN to_date('01-JAN-1901', 'DD-Mon-YYYY') else
  trunc(vendor.EVENT_START_DATE) END) AND to_char(to_date(case when contract.ANNOUNCEMENT_DATE is null then case when contract.ANNOUNCEMENT_QUARTER='Q1' then '1-JAN-' when contract.ANNOUNCEMENT_QUARTER='Q2' then '1-APR-'
  when contract.ANNOUNCEMENT_QUARTER='Q3' then '1-JUL-' when contract.ANNOUNCEMENT_QUARTER='Q4' then '1-OCT-' end || contract.ANNOUNCEMENT_YEAR else to_char(contract.ANNOUNCEMENT_DATE) end),'dd-MON-YYYY') &lt;= (CASE WHEN vendor.EVENT_END_DATE is null THEN to_date('01-JAN-2101', 'DD-Mon-YYYY') else 
  trunc(vendor.EVENT_END_DATE) END));
  </code></pre>
  
  <p>Please help me, Any answer would be appreciated.</p>
  
  <pre><code>Error report:
  SQL Error: ORA-01861: literal does not match format string
  01861. 00000 -  "literal does not match format string"
  *Cause:    Literals in the input must be the same length as literals in
             the format string (with the exception of leading whitespace).  If the
             "FX" modifier has been toggled on, the literal must match exactly,
             with no extra whitespace.
  *Action:   Correct the format string to match the literal.
  </code></pre>