Lets calculate current year minus 3 years data usingpySpark You can achieve this usingF.add_months(current_date(),-36)option
You also have the option to change the dates/year to start . In order to achieve this use F.trunc("end_date", "month") and F.trunc("end_date", "year")