zoukankan      html  css  js  c++  java
  • 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' )
  • 相关阅读:
    linux Mysql 安装
    百度地图的一些操作
    Angularjs Table
    liunx安装mongodb
    ARP协议
    Python获取IP的方式与意义
    selenium 的使用--持续更
    使用pyquery
    beautiful soup的用法
    内置函数
  • 原文地址:https://www.cnblogs.com/hongdada/p/6146050.html
Copyright © 2011-2022 走看看