Code: Select all
currentDateAndTime = datetime.now()
current_month = currentDateAndTime.strftime("%m")
current_year = currentDateAndTime.strftime("%Y")
first_day_of_month = date(int(current_year), int(current_month), 1)
print(first_day_of_month)
type(first_day_of_month)
< /code>
und Sie erhalten: < /p>
2022-10-01 datetime.date
Wenn ich dann
machedf = spark.sql("""
SELECT * FROM table_A
WHERE IncidentCreatedDate < {}
""".format(first_day_of_month))
< /code>
Ich erhalte einen Fehler mit der Aufschrift < /p>
AnalysisException: cannot resolve '(table_A.`IncidentCreatedDate` < ((2022 - 10) - 1))' due to data type mismatch: differing types in '(tableA.`IncidentCreatedDate` < ((2022 - 10) - 1))' (date and int).; ...
< /code>
Möglicherweise gibt es einen Tippfehler in allem oben, weil ich alles auf einem anderen Laptop ausgeben musste überall sonst.)