Reputation: 5081
Using SQLite, trying to get every Appointment
that its date + duration
is between start_date
and end_date
. When adding an appointment with a certain date and 13:00
as an hour and duration of 40
. Using start_date
of 13:30 with duration of 40, it gives empty results (should find the aforementioned appointment).
appointment_end_date = func.datetime(
Appointment.date, f"+{Appointment.duration} MINUTES"
)
query = Appointment.query.filter(
and_(start_date <= appointment_end_date, appointment_end_date <= end_date
)
)
When changing +{Appointment.duration}
to 40, it works. How can I use a column inside this expression?
Upvotes: 0
Views: 114
Reputation: 5081
A possible solution:
func.datetime(func.strftime("%s", Appointment.date) + Appointment.duration * 60, "unixepoch")
Upvotes: 1