Working with events, I’m trying to get the value of a date type attribute and the result is a number, instead of a date.
I’ve tried for different date type attributes and with different logical units and tables, and the result is always the same.
For example:
Logical Unit: ExpenseHeader
Table: Expense_Header_tab
Attribute: CONFIRM_DATE
When the event is executed, I get “1994” as a result, but it should be “16/10/2020”.
Does anyone know how to resolve?.
Thanks in advance,
Amaia
Best answer by Tomas Ruderfelt
Can you try the code below instead and you should see the value of &NEW:CONFIRM_DATE more clearly, separated from the other value you trace out.
Since all attributes are strings you can’t just use them directly. In my example below I have put ' around it for PLSQL to know that it is a string. You should always handle it as a string.
Are you assigning date type column values to any variables before use in the condition? If so please check you use date type variables. If they are string type use the correct converting like = to_char(date_column, ‘YYYY-MM-DD’).
And also check the event side column data type as well.
Event attributes are always strings when you use them.
When you select an attribute to be used in the event you can define what the attribute shall contain:
DATE Date without timestamp
TIME Timestamp without date
DATETIME Date and timestamp
The format of the string for the three different DATE formats are defined in the picture below and you can change it to your preferred format. Observe! This format is for all events.
Can you try the code below instead and you should see the value of &NEW:CONFIRM_DATE more clearly, separated from the other value you trace out.
Since all attributes are strings you can’t just use them directly. In my example below I have put ' around it for PLSQL to know that it is a string. You should always handle it as a string.
For one hand, I replaced &NEW:CONFIRM_DATE by ‘&NEW:CONFIRM_DATE’ int the Error_sys as Tomas indicated, and it worked.
By the other hand, I wanted to compare CONFIRM_DATE and TRUNC(SYSDATE,’MM’), but date formats are different and the comparision was wrong (Confirm_date = ‘2020-10-13’, Trunc(sysdate,’mm’)=’01-OCT-20’). I had to define date variables to work with similar date formats and be able to compare correctly.
We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.