The Way to Programming
The Way to Programming
SELECT * FROM Table WHERE CONVERT(datetime, REPLACE(STUFF(StartTime, 11, 1, ' '), '.', ':')) >= :param1 AND CONVERT(datetime, REPLACE(STUFF(EndTime, 11, 1, ' '), '.', ':')) < :param2
Explanation: SQL likes a datetime format of yyyy-mm-dd hh:mm:ss.
The STUFF command "stuffs" a space in position 11 where the hypen (-) is.
The REPLACE command "replaces" those periods with colons.
At that point the fields can be CONVERTed to datetime types.
Sign in to your account