简体   繁体   中英

SQL Query to comparing the minutes in SQL 2008 R2 server

What am trying to do is, I have table with Date field. Date field has entry in datetime format. Using that i have to display todays records after 5PM. Can anyone help me on this to get this query.

Thanks

Try this.

Select *
FROM tablename
WHERE datefield < '1/1/2014 17:00:00.000'
select * from table1
where 
CONVERT(date,Datefield) = CONVERT(date,GETDATE()) and
CONVERT(time,Datefield) > convert(time,'17:00')

After 5 Pm ? Try this:

select *From Table where DATEPART(hh,yourdatefield)>=17 and and convert(date,yourdatefield,103)='2014-04-03'

this will the the records after 5pm .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM