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!

Adding a number to a date using an PL/SQL Insert Statement in APEX

FriendlyToooSep 15 2021

Hi Folks:
I have one field in Apex that is a date field (:P4_PASTURE_START_DATE). I want to add a number to that date (the reason: an event will include a start date and the user will put how many days it will occur over. The saved data will be converted to a a date).
The Field that contains the number is: :P4_PASTURE_END_DATE. It is actually just a number field.
The problem I have is that when the :P4_PASTURE_START_DATE and :P4_PASTURE_END_DATE I get an ORA-01722: Invalid Number Error.
error.PNG to_date(to_char(:P4_PASTURE_START_DATE + :P4_PASTURE_END_DATE, 'MM/DD/YYYY')),
TO_DATE(:P4_PASTURE_START_DATE +:P4_PASTURE_END_DATE),
I tried hard coding the end date as just a number and received the same error:
to_date(:P4_PASTURE_START_DATE + 5, 'MM/DD/YYYY'),
to_date(to_char(:P4_PASTURE_START_DATE + 5) 'MM/DD/YYYY'),
I'd appreciate any ideas/help in how to code this for a custom PL/SQL Insert (I am able to insert all the other fields ok, just not this one).
Summary:
I need to add :P4_PASTURE_START_DATE (date field) + :P4_PASTURE_END_DATE (number field) to add the extra days to the start date ( so Pasture_Start_Date is a date such as 09/14/2021 and the End date might be 5. I want to save the end_date as as the start date with 5 days added to it (so 09/19/2021).
Any help is appreciated ...
Matthew

This post has been answered by Jan Gorkow on Sep 15 2021
Jump to Answer
Comments
Post Details
Added on Sep 15 2021
4 comments
1,818 views