Quantcast
Channel: SCN: Message List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 9165

Re: Display last 3 months from the entered date in SAP HANA

$
0
0

ADD_MONTHS is SQL function. It will not work.. you need to do something like this..

 

  • Create a calculated column for holding the value of 3 months back month year.
  • In the projection filter, you need to use the filter something like CALMONTH = "CALCULATED_CAL_MONTH_3".
  • set the formula for CALCULATED_CAL_MONTH_3 similar to this logic.. The below logic is to derive the year, you need to concatenate (using || ) similar logic for month.

 

if(in(rightstr('$$IP_CALMONTH$$', 2), '01', '02', '03')=1, string(int(leftstr('$$IP_CALMONTH$$', 4))-1), leftstr('$$IP_CALMONTH$$', 4))

 

The logic checks, if the last 2 chars (month value) is 01, 02, 03 then it will deduct 1 from the year part.. you need to write similar logic to check if month value is in 01, 02, 03, then you need to derive month as (month value + 9), else month value.

 

Regards,

 

Ravi


Viewing all articles
Browse latest Browse all 9165

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>