I'm attempting to create a datetime variable for the start of the day. Ultimately, so I can pass it into various queries (like example below) via an f string.
import datetime
start_datetime = datetime.datetime.today()
query = f""" (SELECT *
FROM TABLE_NAME
WHERE datetime_var >= '{start_datetime}'
)"""
I'm having trouble working out how to get zero hours into the datetime/timestamp.
This is what I've tried:
from pyspark.sql.functions import to_timestamp
# attaching '00:00:00' to the date
start_date = datetime.date.today()
start_dt = to_timestamp(str(start_date)+' 00:00:00')
print(start_dt)
>>> Column<b'to_timestamp(`2020-02-10 00:00:00`)'>
This doesn't resolve into a value. I've not been able to work out what else to try.
How can I get the midnight of the current day timestamp?
Thanks in advance.