如何在SQL中过滤columntype time(7) [英] How to filter the columntype time(7) in SQL

查看:62
本文介绍了如何在SQL中过滤columntype time(7)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Dear,
 
I have a Column Name Emp_InTime DataType time(7). The Data is below.
 
Emp_Name             Emp_InTime
A                    08:00:00
B                    08:19:00
C                    08:00:00
D                    09:00:00
 
Now i want to filter who is coming after 08:15:00
 
How to do it in SQL.
 
Thanks
Basit. 





我的尝试:



从出勤地点选择*(Emp_InTime> CONVERT(DATETIME,'2016-05-08 08:15:00',102))



What I have tried:

Select * from Attendance WHERE (Emp_InTime > CONVERT(DATETIME, '2016-05-08 08:15:00', 102))

推荐答案

你为什么?使用TIME(7)列,并将其与DATETIME进行比较?

只需转换为TIME(7):

Why are you using a TIME(7) column, and comparing it with a DATETIME?
Just CONVERT to a TIME(7) instead:
SELECT * FROM Attendance WHERE (Emp_InTime > CONVERT(TIME(7), '2016-05-08 08:15:00', 102))


不要忘记您可以将代码放在SQL查询窗口中并尝试不同的东西。



我认为这个小片段会帮助你。

Don't forget that you can put code in the SQL query window and try different things.

This little snippet will help you, I think.
declare @in_time TIME;
set @in_time = CONVERT(TIME, '08:17:00');
select IIF(@in_time > CONVERT(TIME, '08:15:00'), 'late', 'on time');
go;


这篇关于如何在SQL中过滤columntype time(7)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆