sqlapache-spark-sqldatabricks-sql

Date set in parameter does not match with date when querying the parameter


enter image description here

As you can see in the screenshot I set a parameter with datatype date and selected the date 2024-05-27.

However, when I query this parameter in SQL, I am getting a completely different value (1992-01-01).

Do you know why this is the case and how to solve it?


Solution

  • The thing you need to do to get this parameter is:

    SELECT '{{start_date}}'
    

    Then you can cast it to date with:

    SELECT TO_DATE('{{start_date}}')