How to set default value on date picker ( sysdate + :pageitem) (Not working) Oracle Apex

382 Views Asked by At

I have 2 date picker on Oracle Apex page ; P7_REQDEPARTUREDATE and P7_REQARRIVALDATE.

P7_REQDEPARTUREDATE need to 'tomorrow' value = sysdate +1

P7_REQARRIVALDATE need to '10 days later' value = sysdate + 10

I adjust their default with this ; to_char(sysdate + 1,'DD-MM-YYYY') and to_char(sysdate + 10,'DD-MM-YYYY') was working BUT they don't want me to do statically so I need to fix it.

I have hidden page items ; P7_493DEPDATE (value is 1 ) and P7_493ARRDATE (value is 10) ( the values coming from sql query) (varchar)

SO this is not working or the changes that I can imagine not working so I'm doing something wrong but I don't know what .

For example;

to_char(sysdate + :P7_493DEPDATE,'DD-MM-YYYY') (not working)

to_char(sysdate + $v('P7_493DEPDATE'),'DD-MM-YYYY') (not working)

at this point I don't know if I need to create DA or should I try to do it with default value. Thanks

(I checked the similar questions couldn't help myself)


UPDATE 22 November 2023

First of all thank you for your answer, both your answers seems usefull. I found to how to fix it before I get any answer so I couldn't write anything here . I fixed the problem by creating Dinamic action and set value . Thank you for your time again! I appreciated that! (I will not delete the question so other people can get help from it too.)

setvalue-photo

inside-setvalue

2

There are 2 best solutions below

0
On

I presume that P7_493DEPDATE's sequence is higher than P7_REQDEPARTUREDATE:

enter image description here


For P7_493DEPDATE item, source is query that returns single value:

SELECT 10 FROM DUAL

For P7_REQDEPARTUREDATE date picker item, source is expression:

to_char(sysdate + :P7_493DEPDATE, 'dd-mm-yyyy')
1
On
P7_REQDEPARTUREDATE - +1d

P7_REQARRIVALDATE - +10d

if not static then create a dynamic action on change event on P7_REQDEPARTUREDATE to update P7_REQARRIVALDATE.


event type- set value.
set type plsql expression -

to_date(P7_REQDEPARTUREDATE,'DD-Mon-YYYY') +10
item to submit P7_REQDEPARTUREDATE