cancel
Showing results for 
Search instead for 
Did you mean: 

Recent 3 months from Date Object

Former Member
0 Kudos

Hi,

I need to create a object to bring recent 3 of data from a date object.

Actual Data

Report_Year_Month
201212
201301
201302
201303
201304
201305
201306
201307

Expecting

Recent 3 Months
201305
201306
201307

I tried to get hte expected by floowing way of no use.

Recent 3 Month==> add_months(to_date(Report_Year_Month ,'YYYYMM'),-1)

What i am getting is "201305"

Please give some sugessions to get recent 3 months.

Environment BO XI R3

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Create a predefined condition in the universe as:

table.date BETWEEN add_months(trunc(sysdate,'mm')-3) AND trunc(sysdate,'mm')-1

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Praveen,

If you looking for report Year Month restricted for last three month excluding current month then below would be your universe object.

LastMonthYear=Case When Month(SysDate)=01 Then Year(SysDate)-1 Else Year(SysDate) End

LastMonth=Case When Month(SysDate)=01 Then 12 Else Month(SysDate) End

LastMonthYYYYMM=To_date(@Select(ABC\LastMonthYear)+@Select(ABC\LastMonth);"YYYYMM")

Create condition object as below and use it in the report to restrict data in report for Last 2 Report year months.


=Report_Year_Month Between add_months(@Select(ABC\LastMonthYYYYMM),-2) and @Select(ABC\LastMonthYYYYMM)

Thanks

Mallik