databricks python dateadd

arkiboys 9,686 Reputation points
2022-04-22T09:25:21.497+00:00

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

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

Undefined function: 'DATEADD'

Question:
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
    2022-04-25T10:38:58.03+00:00

    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.
    196171-image.png

    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