2
votes

I have a table with 2 dates begin_date and end_date. I have an Oracle APEX form that fetches data from this table. Is it possible on APEX side to calculate number of days between begin_date and end_date?

As far as I understand, I cannot create an item referring directly to an expression end_date-begin_date. I tried to create two hidden items: P_BEGIN_DATE referring to begin_date column and P_END_DATE referring to end_date column. And then create third item referring to an expression :P_END_DATE-:P_BEGIN_DATE. But this does not work because :P_BEGIN_DATE and :P_END_DATE appear to be strings, not dates.

Is there a way to calculate this difference without creating virtual column on database side?

P.S. I Use quite old version of APEX: 4.2.1. But if you know solution for newer version, please write it as well

1

1 Answers

1
votes

everything in html is text, this means that all Apex items are string.

if you need to do calculations with the items, you need to convert them to the correct format

to_date(:P_END_DATE, 'MM/DD/YYYY') - to_date(:P_BEGIN_DATE, 'MM/DD/YYYY')