sql 时间差
select * from Tickets
where
(
case when UnloadTime is null
then datediff(hh,LoadTime,getdate())
else datediff(hh,LoadTime,UnloadTime)
end)>=48
这种方式是可以的
Linq时间差:
//linq = linq.Where(x => System.Data.Entity.Core.Objects.EntityFunctions.DiffMilliseconds(x.LoadTime, x.UnloadTime)>48);
linq = linq.Where(x => System.Data.Entity.DbFunctions.DiffHours(x.LoadTime, x.UnloadTime) >= 48);
上面一种就很旧版本,下面是新的版本
sql时间方法应用
获取某日期的当天开始时间:
declare @Now datetime='2017-11-29 15:49:00';
--获取@Now日期的开始时间,例如-2017-11-29 00:00:00.000
declare @MinTodayTime datetime=convert(datetime,convert(varchar(10),@Now,120));
select @MinTodayTime;
datediff:
SELECT datediff( day,'1999/07/19 23:00','1999/07/20 01:59' )
sql 时间差的更多相关文章
- SQL 时间差函数
SELECT DateDiff(DAY,T.ActualEndDate,GetDate()) FROM JCW_CheckTask T WHERE T.status = 2
- SQL求解两个时间差
sql 求解两个时间差 SELECTDATEDIFF( Second, '2009-8-25 12:15:12', '2009-9-1 7:18:20') --返回相差秒数 SELECTDATEDIF ...
- sql查询两条记录的时间差
今天突然想到了一个需求,即在一张带有id和time字段的表中,查询相邻时间的时间差. 表的记录如下: 表名为wangxin id是一个不重复的字符串,time是一个时间戳. 现在的需求如下: 比如id ...
- Sql Server中使用存储过程来实现一些时间差的改变
Sql Server中的时间差是使用DATEDIFF来是现的 语法如下:DATEDIFF(要显示时间格式,开始时间,结束时间) 比如:DATEDIFF(minute,'2019-2-28 8:30', ...
- SQL计算时间差并排除周末
SQL计算时间差并排除周末 CREATE FUNCTION DI_FN_GET_WorkDay (@begin DATETIME , @end DATETIME ) RETURNS int BEGIN ...
- 断今天日期和指定日期相等和两者的时间差为两年的sql
1. ---判断今天日期和指定日期相等 update store set Status =1 where CONVERT(varchar(12) ,opendate, 105 )= CONVERT ...
- 常用的获取时间差的sql语句
"select count(*) from [注册] where datediff(day,time,getdate())<1";//获取当天注册人员数 sql=" ...
- 求时间差的sql语句。 比如如下数据
msisdn createtime closetime138 2011-5-17 15:30:00:000 2011-5-17 15:30:00:530138 2011-5-17 15:40:00:0 ...
- SQL 建表与查询 HTML计算时间差
create database xue1 go --创建数据库 use xue1 go --引用数据库 create table xinxi ( code int, name ), xuehao ), ...
随机推荐
- js 过滤敏感词
<html> <head> <title>Bad Words Example</title> <script type=" ...
- ACM: POJ 1401 Factorial-数论专题-水题
POJ 1401 Factorial Time Limit:1500MS Memory Limit:65536KB 64bit IO Format:%lld & %llu ...
- jQuery的Dom插入操作图示
- 如何将一个对象存到网页中并在js中使用
需求:希望在js中使用Controller传过来的对象,特别是对象里存有list的数据. 不希望循环使用隐藏域. 解决办法:在View中使用Json.Net序列化: @{ string jsonStr ...
- HBase1.0以上版本的API改变
HBase1.0以上版本已经废弃了 HTableInterface,HTable,HBaseAdmin等API的使用,新增了一些API来实现之前的功能: Connectioninterface: Co ...
- webkit内核浏览器的CSS写法
-webkit-tap-highlight-color: transparent; Mobile上点击链接高亮的时候设置颜色为透明 -webkit-user-select: none; 设置为无法选择 ...
- 19.创建如下三个类:(People类中的三个方法分别输出一些信息,ChinaPeople 和AmericanPeople类重写父类的三个方法)。
package zuoye2; public class People { protected double height; protected double weight; private Stri ...
- Button,CheckBox,Lable,RadioButton,ComboBox,TextBox六个简单控件的使用
所有文字的更改全部在Text属性中更改! ComboBox:点击右上方小箭头,选择编辑项弹出: RadioButton:,Checked属性选择True,表示已被选中: Button:在设计中双击按钮 ...
- .offsetLeft,.offsetTop
*{ margin:0; padding:0} div {padding: 40px 50px;} #div1 {background: red;} #div2 {background: green; ...
- mysql sql注入
防止SQL注入,我们需要注意以下几个要点: 1.永远不要信任用户的输入.对用户的输入进行校验,可以通过正则表达式,或限制长度:对单引号和 双"-"进行转换等. 2.永远不要使用动态 ...