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 ), ...
随机推荐
- flex设置成1和auto有什么区别
首先明确一点是, flex 是 flex-grow.flex-shrink.flex-basis的缩写.故其取值可以考虑以下情况: flex 的默认值是以上三个属性值的组合.假设以上三个属性同样取默认 ...
- 20145308刘昊阳 《Java程序设计》第2周学习总结
20145308刘昊阳 <Java程序设计>第2周学习总结 教材学习内容总结 第三章 基础语法 3.1 类型.变量与运算符 类型 基本类型 整数(short/int/long) short ...
- Leetcode Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...
- 读取和写入 文件 (NSFIleManger 与 NSFileHandle)
读取和写入 文件 //传递文件路径方法 -(id)initPath:(NSString *)srcPath targetPath:(NSString *)targetPath { self = [su ...
- 【URAL】1960. Palindromes and Super Abilities
http://acm.timus.ru/problem.aspx?space=1&num=1960 题意:给一个串s,要求输出所有的s[0]~s[i],i<|s|的回文串数目.(|s|& ...
- iOS 项目中用到的一些开源库和第三方组件
iOS 项目中用到的一些 iOS 开源库和第三方组件 分享一下我目前所在公司 iOS 项目中用到的一些 iOS 开源库和第三方组件, 感谢开源, 减少了我们的劳动力, 节约了我们大量的时间, 让我们有 ...
- OSG中的示例程序简介
OSG中的示例程序简介 转自:http://www.cnblogs.com/indif/archive/2011/05/13/2045136.html 1.example_osganimate一)演示 ...
- [LintCode] Create Maximum Number 创建最大数
Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum numb ...
- ZK 代码自动提示
1.设置xsd 打开eclipse,Window-Preference,进行如下设置: 2.创建zul文件 (1)打开File—New—Other窗口,新建XML File文件: (2)选择新建文件所 ...
- WebApp 里Meta标签大全,webappmeta标签大全
1.先说说mate标签里的viewport: viewport即可视区域,对于桌面浏览器而言,viewport指的就是除去所有工具栏.状态栏.滚动条等等之后用于看网页的区域.对于传统WEB页面来说,9 ...