Assuming that your column has a data type of datetime you’ll need to use a CONVERT statement in your WHERE clause to find the data you are looking for.
This query will return all the values where the time is within 5 minutes after noon, or the highest value before noon.
JOIN (SELECT IdColumn, convert(varchar(10), YourColumn, 101) DateColumn, max(YourColumn)
WHERE CONVERT(VARCHAR(10), YourColumn, 108) > ’12:05:00 PM’
GROUP BY idColumn, convert(varchar(10), YourColumn, 101)
) t1 ON TAble.IdColumn = t1.IdColumn
This query will be very slow to run as you will not be able to use an index to search the table. An index scan or table scan will be required because you are doing a convert against the column in the table.
This example assumes that the date and time are stored in a single field.