与系统时间的时间比较 [英] Time comparison w.r.t the system time

查看:128
本文介绍了与系统时间的时间比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,

我需要一个查询,该查询给出特定的投诉编号,该编号具有固定的持续时间(例如6小时),必须解决其他问题才能显示为输出..

现在我的问题是我将投诉记录的时间增加了6个小时,并将其与系统时间进行了比较.这是我的查询..

hello friends,

I need an one query that gives particular complaint number which has some fixed time duration like 6hrs within that it has to solved other wise that should be displayed as output..

Now my problem is i''m adding that 6hrs to the time at which complaint has registered and comparing it with the system time.. here''s my query..

"select compno,compdate,comptime from urbrur where status='Under Process' and DATEADD(hh,6,comptime)<=GETDATE()"


但是得到的输出是不一致的. .


but the output ''m getting is inconsistent . .

Compno Compdate comptime
16388 8/31/2011 10:11 AM
16790 9/15/2011 8:29 PM
16905 9/22/2011 5:05 PM
16906 9/22/2011 5:37 PM
17068 9/30/2011 5:24 PM
17085 10/1/2011 6:43 PM
17086 10/1/2011 6:48 PM
17087 10/1/2011 6:53 PM



这是我的smaple数据,在10月1日下午7:17的系统时间获取.

所以在这个查询和这个系统时间上,因为我认为不应显示最后3个投诉,因为17085 6:43 pm + 6hrs表示12:43 am不是< =当前系统时间7:17 PM,然后该投诉不应显示11月.然后,请给我建议朋友,最近10天以来我非常需要它. .

朋友另一件事就是说



this is my smaple data fetching it at the system time of 7:17 PM on october 1st.

so w.r.t this query and with this system time as i think the last 3complaints should not be displayed i''e, for 17085 6:43pm + 6hrs means 12:43am is not <= current system time 7:17 PM then that complaint nomber shouldn''t be displayed..then kindly plz suggest me friends, i''m very much needed from last 10days . .

friends other thing is to say that the

compno-numeric;compdate-nvarchar(50);comptime-nvarchar(50);



我正在使用带有C#的SqlServer2000,VS2008,ASP.Net
谢谢
praveen



And i''m using SqlServer2000,VS2008, ASP.Net with C#

Thanking You,
praveen

推荐答案

最好将日期和时间也存储为datetime列,这样您的查询将在该列上正确运行.

It is better to store the date and time together as a datetime column as well, then your query will run correctly on that column.

select compno,compdate,comptime from urbrur where status='Under Process' and DATEADD(hh,6,CAST(compdate + ' ' + comptime as datetime)<=GETDATE()


听起来像您在工作流应用程序上工作,所以我认为您可能会发现Workflow基础很有趣:
直接启动Windows Workflow Foundation [ MSDN [
Sounds like you are working on a workflow application, so I thought you might find Workflow foundation to be of some interest:
Jump start Windows Workflow Foundation[^]

There are some tutorials available on MSDN[^] too.

Best regards
Espen Harlinn


您声明12:43AM > 7:17 PM,但这不是事实.

您还必须使用日期.
You state that 12:43AM > 7:17 PM but that''s not true.

You''ll have to use the date as well.
select compno,compdate,comptime
from urbrur
where status='Under Process' and
      DATEADD(hh,6,compdate + ' ' + comptime) <= GETDATE()


这篇关于与系统时间的时间比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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