Skip to content
Advertisement

How to not have time be a bind parameter in SQL, but have a parameter be bound?

I wish to select orders from after 23:00:00 but have a prompt for date selection, but when I use bind parameters the time is recognised as a parameter for binding since it contains “:”, what is a workaround for this? I need just OrderDate to be a bind parameter.

WHERE TimeOfOrder >'23:00:00' AND DateOfOrder = :OrderDate;

Screenshot showing bind parameters “:00” and “:OrderDate”

Advertisement

Answer

I found that using CAST(” “) for the time stopped the environment from seeing 23:00:00 as a possible bind parameter.

WHERE DateOfOrder =':OrderDate' AND TimeOfOrder >=CAST("230000" AS TIME)

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement