01-05-2019 1:04 PM
Hi experts,
I have two dates based on their differences I need to calculate months from them.
Previously in ECC we were using FM: 'FIMA_DAYS_AND_MONTH_AND_YEARS to calculate months. I search many SDN blogs, but I can't find any solution on this.
Can this is possible in CDS view to calculates months directly, like we use to calculate date difference using
Function DATS_DAYS_BETWEEN or any other suggestion to achieve this logic in Hana?
Thanks,
Mahendra
Information added by Moderator: An ABAP CDS view is implemented, not a HANA CDS View.
01-05-2019 2:40 PM
Can you please tell me how I will use function DAYS_BETWEEN in existing CDS joining Query?
I am using this way,
DAYS_BETWEEN(audat, vdatu) as no_of_days
but getting syntax error that function days_between is unknown.
01-05-2019 2:42 PM
What HANA version you are using?
You are sure that you are using HANA CDS views and not ABAP CDS views?
Can you show your whole CDS View syntax?
01-05-2019 3:05 PM
01-05-2019 3:32 PM
Hi gaurav mahendra,
You have another function availbe in CDS:
DATS_DAYS_BETWEEN(date1,date2) @Florian Pfeffer thanks, i didn't see that it is available. Just checked 🙂
Ignore below:
****If you are using ABAP CDS****
You need to use the combination of AMDP, Table function & CDS view to achieve this. Check the answer and the mentioned blog below, instead of date to day and month you need to use days between function in the AMDP
https://answers.sap.com/questions/704604/cds-date-to-daymonth.html?childToView=703560#answer-703560
BR,
Mahesh
01-05-2019 3:41 PM
When you get that error, than it seems that you are not using a HANA CDS View, but an ABAP CDS View.
What NetWeaver version are you using (as you mentioned function DATS_DAYS_BETWEEN in your question and is not available I think, otherwise you would have used it)?
01-07-2019 2:23 PM
The function module FIMA_DAYS_AND_MONTHS_AND_YEARS is not released to customer use, which may explain the lack of SDN blog entries.
I may be underestimating the complexity of your task but have you considered simply subtracting the month values from each other? In the example code, the Parameters would be substituted with the specific fields you are working with, of course.
PARAMETERS: p_from TYPE sy-datum DEFAULT sy-datum,
p_to TYPE sy-datum.
DATA: answer TYPE numc04.
START-OF-SELECTION.
answer = p_to+4(2) - p_from+4(2).
WRITE answer.