4
votes

There is a hidden field as last_updated_date in my Oracle Apex application form. I have set SYSDATE as default value of that field. After adding data, I'v checked database table and data in last_updated_date column is show as 15-JUN-12 00:00:00. Time is not saved.

How could I save both date and time?

3

3 Answers

9
votes

In the hidden item's properties set:

  • Source Format Mask to DD-MON-YYYY HH24:MI:SS
  • Default Value to TO_CHAR(SYSDATE,'DD-MON-YYYY HH24:MI:SS')
  • Default Value Type to PL/SQL Expression
0
votes

In 4.2.6 that does not work. It will only work with format dd-mon-yyyy or your standard database format (NLS_FORMAT). The other thing you could do is try to set default formats at application level for your app. That might work. It seems that for hidden fields the formatting does not get honoured for default values and hence you run into errors like "ORA-01830: date format picture ends before converting entire input string"

0
votes

Above answers didn't work. In Apex 4.2 (or probably higher) Try this:

Display as: Text Field (didn't try hidden yet)
source used: "Always, replacing any existing value in session state"
source type: "Database Column"
Source value or expression: 'COLUMN_NAME' case sensitive
Post Calculation Computation: to_char(sysdate,'mm/dd/yyyy hh24:mi') format mask: "mm/dd/yyyy hh24:mi"(no quotes)
Dafault value: sysdate
Default Value Type: PL/SQL Expression

In "Processes" - After Submit
Type: PL/SQL Anonymous Block
On Submit - After Computations and Validations
Declare

begin
update table_name
set column_name = sysdate
where trunc(sysdate) = column_name;

commit;

end;