An Apache Spark-based analytics platform optimized for Azure.
Hi @arkiboys,
Thank you for posting query in Microsoft Q&A Platform.
You can use the
datetimemodule anddateutillibrary to get the previous date, year and month in PySpark.
from datetime import datetime
from dateutil.relativedelta import relativedelta
# Get the previous date
previous_date = datetime.today() - relativedelta(days=1)
# Get the previous year
previous_year = datetime.today() - relativedelta(years=1)
# Get the previous month
previous_month = datetime.today() - relativedelta(months=1)
Hope this helps. Please let me know if any further queries.
Please consider hitting Accept Answer button. Accepted answers help community as well.