on 06-06-2015 7:25 PM
Hi All,
My Requirement is like - Master data table (Example below) having employee ID, From_Date.and To_date. Based on the current date, I would return data that is valid for today.
Example, My desired output would be from below table is only EMp_ids. since emp_id's are ignored since to_date is expired based on current date.
Table:
Emp_id From_date | To_date |
can you some one please give me suggestion to achieve this logic. | |
Thank you |
Hi Vasu,
just use the HANA date / time "function" CURRENT_DATE for that (ok, it is more like a global variable). You could try to use that in the filter condition directly (e.g. "FROM_DATE" >= CURRENT_DATE etc. ) or to add a new calculated column whose expression evaluates to CURRENT_DATE and use that column in the filter conditon.
I would rather prefer to use an input parameter of the view, because it is better unit testable. You can't unit test the current date very good.
Best regards,
Kilian.
You can find this function here: https://help.sap.com/saphelp_hanaone/helpdata/en/20/ddfe5d75191014af50837e2818462d/content.htm
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vasa,
Is the current date an input Parameter to the view? Then you could just apply a filter condition in a projection node stating
"BEGIN_DATE" <= "$$CURRENT_DATE$$" AND "END_DATE" >= "$$CURRENT_DATE$$"
If I remember the filter editor correctly, you can enter arbitrary expressions in there, just like in an ordinary SQL statement. Just like so:
Best regards,
Kilian.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vasu,
do you mean that you want to SELECT data from a table which is according to your description? Then something like:
SELECT DISTINCT emp_id FROM table WHERE from_date <= current_date AND
to_date >= current_date.
should do the job.
According to the data you may or may not need the DISTINCT in the SELECT statement.
Best regards,
Kilian.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.