Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ORA-01481: Invalid number format model, for a DATE datatype

buggleboy007May 12 2022

Hi all,
I am trying to fetch values from a table called SZTPAYM. There are 10 records against the dates that I am passing in the said table.
Capture1.JPG
The problem that I have is with the date column called SZTPAYM_TRANS_DATE. The datatype of this column is DATE.
When I run the following query I have to input the from date (via &v_from_date) and its format is: 200110200000 plus the to date (via &v_to_date) and it's format is: 200110312359.
The query fails with ORA-01481: Invalid number format model. How can this be fixed?

SELECT sztpaym
_aidm,
       (SELECT SA.SABIDEN_PIDM FROM sabiden SA WHERE sabiden_aidm = s.sztpaym_aidm) PIDM,
        sztpaym_term_code_entry, 
        sztpaym_type_ind,
        sztpaym_detail_code,
        sztpaym_trans_date,
        sztpaym_dr_cr_ind,
        sztpaym_trans_amt,
        sztpaym_order_number,
        sztpaym_description
    FROM  sztpaym S
    WHERE sztpaym_TYPE_IND = 'C' 
    AND  sztpaym_order_number IN ( SELECT sztpaym_ORDER_NUMBER
                     FROM  sztpaym
                     WHERE sztpaym_detail_code IN ('ADWA', 'ADAF', 'ADAE')
                     AND  sztpaym_trans_date BETWEEN TO_CHAR('&v_from_date','YYYMMDD HH24:MI') AND TO_CHAR('&v_to_date','YYYYMMDD HH24:MI')
                     AND  sztpaym_RESPONSE_IND BETWEEN '000' AND '049'
                   )
   ORDER BY sztpaym_aidm,sztpaym_trans_date; 
This post has been answered by cormaco on May 12 2022
Jump to Answer
Comments
Post Details
Added on May 12 2022
4 comments
5,529 views