Last month date of previous month
Case 1
If you have any date and you want to calculate last month date of previous month in data dataiku function then use "inc" and "datePart" function.
inc(dt,toNumber(concat('-',datePart(dt,'Day'))),'day')
Example : Parameter date - 2023-06-26
Result :- 2023-05-31
Case 2
If you have specific date and you want to get last month date of previous months or 2 previous month data then use below code
inc(inc(asDate("2023-06-26","yyyy-MM-dd"),toNumber(concat('-',datePart(asDate("2023-06-26","yyyy-MM-dd"),'Day'))),'day'),-1,'months')
Example : Parameter date - 2023-06-26
Result :- 2023-04-30
Comments
Post a Comment