我如何选择两次之间的小时数,例如(18:00& 22:00)= 4 [英] how can i select hours between two times eg(18:00 & 22:00)=4

查看:105
本文介绍了我如何选择两次之间的小时数,例如(18:00& 22:00)= 4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下午好
我如何选择两次之间的小时数,例如(18:00& 22:00)= 4

下面的代码返回979848,我不明白这个值是什么
你能帮我吗


Good afternoon
how can i select hours between two times eg(18:00 & 22:00)=4

this code below returns 979848 and i dont understand what this value is
can u please help me


USE [DUT_Governance_Department]
GO
/****** Object:  StoredProcedure [dbo].[StudentsRespective_Studlog]    Script Date: 10/13/2011 18:41:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER Proc [dbo].[StudentsRespective_Studlog]
(@User_names char(8)
 
 )
as
select Passwords ,Students.User_names,F_name,Vote_status,Reg_status,Reg_year ,Regions.Region_name,Function_ID.Function_id,DATEDIFF(MONTH, Reg_year,GETDATE())as Month_Diff,Login_try ,DATEDIFF(hour,Try_time, GETDATE())
from Students,Regions,User_Account,Faculty,Campus,Function_ID   
where  Students.User_names =User_Account .User_names 
AND Faculty.faculty_id =Students.faculty_id
AND Campus.Campus_id=Faculty.Campus_id
AND Regions.Region_id=Campus.Region_id
AND Function_ID .Function_id =User_Account.Function_id 
AND Students.Vote_status in('N','Y')
AND Function_ID.Function_id =4
AND Students.User_names =@User_names   

推荐答案

您可以使用两种方法:
中选择 fields ,其中 datefield 在"date/time1"和"datetime2"之间
例如
Select * from Logins where LoginDate between ''01-jan-2011 18:00:00'' and ''01-jan-2011 22:00:00''


OR
Select * from Logins where LoginDate >= ''01-jan-2011 18:00:00'' and LoginDate <= ''01-jan-2011 22:00:00''
You can use a couple of methods;
Select fields from table where datefield between ''date/time1'' and ''datetime2''
e.g.
Select * from Logins where LoginDate between ''01-jan-2011 18:00:00'' and ''01-jan-2011 22:00:00''


OR
Select * from Logins where LoginDate >= ''01-jan-2011 18:00:00'' and LoginDate <= ''01-jan-2011 22:00:00''


这篇关于我如何选择两次之间的小时数,例如(18:00&amp; 22:00)= 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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