Answer the question
In order to leave comments, you need to log in
How to display data by time without affecting the date?
There is a field in the table with date data in it of this form 2019-04-21 22:58:25.437, I need to display data by time, let's say all that are more than 9 hours.
Answer the question
In order to leave comments, you need to log in
https://metanit.com/sql/sqlserver/8.3.php
You can take the date component - time (hour and minute) and compare them with the required ones.
SELECT * FROM table
WHERE DATEPART(hour, [date_field]) > 9
Alexander
's decision is absolutely correct.
But if you need time , then there is a construction:
SELECT CAST( GETDATE() AS DATE), CAST( GETDATE() AS TIME)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question