databricks python dateadd

arkiboys 9,686 Reputation points

I am running a sql query in python cell of databricks notebook as follows
p.workDATE >= DATEADD(M, -9, GETDATE()) \

I get error on:
modular_df = spark.sql(sql)

Undefined function: 'DATEADD'

How do I correct this?
Thank you

Azure Databricks
Azure Databricks
An Apache Spark-based analytics platform optimized for Azure.
2,063 questions
0 comments No comments
{count} votes

Accepted answer
  1. ShaikMaheer-MSFT 38,326 Reputation points Microsoft Employee

    Hi @arkiboys ,

    Thank you for posting query in Microsoft Q&A Platform.

    In Pyspark SQL we should use different functions. In your case you should consider using add_months() function.

    Please check below screenshot to get idea.

    Hope this helps. Please let us know if any further queries.

    Please consider hitting Accept Answer button. Accepted answers help community as well.

    0 comments No comments

0 additional answers

Sort by: Most helpful