如何在两列中找到timeDifferece [英] how to find timeDifferece in two columns

查看:103
本文介绍了如何在两列中找到timeDifferece的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

How to subtract  this: InTime(nvarchar(20)) – OutTime(nvarchar(20))¬¬ in sql server 2005
Values will be in both of columns like 10:00, 10:30, 10:40 etc…

推荐答案

使用此简单的代码将起作用

use this simple code it will work

declare @InTime nvarchar(10) set @InTime='10:00'
declare @OutTime nvarchar(10) set @OutTime='11:30'
select datediff(minute,convert(datetime, convert(char(10), @InTime,110)),convert(datetime, convert(char(10),@OutTime, 110)))


朋友,

这将帮助您...


Hi friend,

this will help you...


DECLARE @A DATETIME
DECLARE @B DATETIME
DECLARE @Secs DECIMAL(18, 2)

SET @A = '2005-08-06 12:08:00.000'
SET @B = '2005-08-18 00:30:19.000'

SELECT @Secs = DATEDIFF(s, @A, @B) / 60.000000 / 60.00000 / 24.000000
select @Secs


亲爱的Dinesh,
希望对您有帮助.
Dear Dinesh,
Hope this will help you.
select DATEDIFF(day,col1,col2) AS NumberOfDays,
DATEDIFF(hour,col1,col2) AS NumberOfHours,
DATEDIFF(minute,col1,col2) AS NumberOfMinutes FROM Your_Table

select DATEDIFF(day,2012-06-19,2012-06-20) AS NumberOfDays,
DATEDIFF(hour,2012-06-19,2012-06-20) AS NumberOfHours,
DATEDIFF(minute,2012-06-19,2012-06-20) AS NumberOfMinutes FROM Your_Table



问候,
AP



Regards,
AP


这篇关于如何在两列中找到timeDifferece的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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