Search code examples
oracle-databaseoracle11goracle-apexoracle-apex-5

Date/ time function


I have a "phone payment" form that have four (4) columns

  • Phone_Number
  • user_name
  • invoice_date
  • invoice_amount
  • exceeding_amount

what I want to accomplish is having the invoice_date set to the 24th of the new month when a new record is entered for each user.

so for example -

January records should show


Phone_number          User_name              invoice_date            invoice_amount           
123456                test                   24/1/2021                  100
678901                testing                24/1/2012                  200

and

February records should show 

Phone_number          User_name              invoice_date            invoice_amount          
123456                test                   24/2/2021                  200
678901                testing                24/2/2012                  300

and so on for the rest of the months


Solution

  • The "now" in your question is sysdate in Oracle.

    To get the 24th day of the current month you can do something like this:

    trunc(sysdate, 'month') + 23
    

    (note: + 23 since the truncated date is already the 1st of the month).

    How you will use this depends on the overall picture (what you are doing with this), which you did not include in your question.