如何将时间与数据库时间进行比较 [英] How to compare time with Database time's
问题描述
大家好,
我有带有datetime数据类型的时间字段,即.来自&致
我为此插入了值,如下所示.
1早餐2012-04-05 07:00:00.000 2012-04-05 10:00:00.000
1午餐2012-04-05 11:00:00.000 2012-04-05 02:30:00.000
我需要准备以下存储过程..
输入参数:用户将通过时间作为输入,即8AM,1PM
输出:我需要检索所有值给用户.
如何将此输入时间与数据库时间进行比较?
在Advance中致谢
尝试:
DECLARE @ TIME TIME = ' 11PM' 选择 * FROM myTable 位置 转换(时间,myDateColumn)> = @ TIME
>
Hi all,
I have time fields with datetime datatypes ie. From & To
I inserted values for that as follows.
1 Breakfast 2012-04-05 07:00:00.000 2012-04-05 10:00:00.000
1 Lunch 2012-04-05 11:00:00.000 2012-04-05 02:30:00.000
I need to prepare storedprocedure for following..
Input parameter: user will pass the time as input ie 8AM, 1PM
Output : i need to retrieve all values to the user.
How can i compare this input time to Database time?
Thanks in Advance
Try:
DECLARE @TIME TIME = '11PM' SELECT * FROM myTable WHERE CONVERT(time, myDateColumn)>=@TIME
这篇关于如何将时间与数据库时间进行比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!