时间相减在转化 如何写这个sql 语句表A (三个字段)
  user_id , time_start ,  time_end  我想计算 time_start与 time_end 之间的(开始时间-结束时间)时间止差是多少??
显示在dbgrid上 select sum((time_start-time_end)*24*60*60) from table //这样好像不对!!!如何写???

解决方案 »

  1.   

    select cast((time_start-time_end) as DateTime) from table
      

  2.   

    sql server数据库
    stime_start ..:datetime类型
      

  3.   

    统计用了多长时间 
    ljmanage(过客) :cast??提示有错!dm.adoq_time.Close;
    dm.adoq_time.sql.Clear;
    dm.adoq_time.sql.Add('select opr a ,case(dt_hookoff-dt_end) from tab_agent_log  
    dm.adoq_time.Open; 有错!!!我想 统计两段时间之间  用了多长时间 
      

  4.   

    sql 语句中*乘号如何写?select a*b from table???
      

  5.   


    select DATEDIFF ( s, time_start , time_end)  from tab_agent_log
    看看sql server中datediff的帮助
      

  6.   

    1 用
    select DATEDIFF ( s, time_start , time_end)  from tab_agent_log
    看看sql server中datediff的帮助2 乘法 * 是对的
      

  7.   

    select datepart(hour, b)*3600+datepart(minute,b)*60+datepart(second,b)-datepart(hour, a)*3600+datepart(minute,a)*60+datepart(second,a) from table
      

  8.   

    select (time_start-time_end)*24*60*60 as spendtime from table 
    或者select DATEDIFF ( s, time_start , time_end) as spendtime  from table
    记得使用as ***,将运算后得到的字段 命名,这样你就可以在程序中引用了,如query.fieldbyname('spendtime').asstring,
      

  9.   

    : firetoucher(风焱)  大哥:我找不到ssql 的 DATEDIFF 的帮助!!
    sql server中的帮助都是如何启动 如何恢复之类的。( s, time_start , time_end)  中 s:=秒 x:=分? x:=小时?
      

  10.   

    写错了,DATEDIFF在有些数据库中是不支持的,而且DATEDIFF语句中不用使用as
      

  11.   

    select DATEDIFF(second,time_start,time-end) from table
      

  12.   

    : wweijie(我是一只小小小小鸟) :select (time_start-time_end)*24*60*60 as spendtime from table 题是错误:对数录类型而言运算符无效。运算符为multiply 类型卫datetime
      

  13.   

    日期部分 缩写 
    year yy, yyyy 
    quarter qq, q 
    Month mm, m 
    dayofyear dy, y 
    Day dd, d 
    Week wk, ww 
    Hour hh 
    minute mi, n 
    second ss, s 
    millisecond ms 
      

  14.   

    select sum((time_start-time_end)*24*60*60) from table //为什末这样不对!!!
    sql server2000数据库
      

  15.   

    看看帮助嘛
    以秒统计
    select DATEDIFF(second,time_start,time-end) from table
    以分统计
    select DATEDIFF(hour,time_start,time-end) from table
    至于
       select sum((time_start-time_end)*24*60*60) from table //为什末这样不对!!!
    如果没有记错的话
    time_start-time_end的结果是个日期类型
      

  16.   

    hjmaAsC(装库) ( :大虾 你来点简单的如何?
      

  17.   

    DateDiff('d',dateandtime,Date()),计算dateandtime字段与当前日期date()之间的天数('d')差,
      

  18.   

    sql="SELECT top 10 * FROM article where (DateDiff('d',dateandtime,Date())<=10   order by hits desc,title" 这段代码在Access 中可用
      

  19.   

    我要具体到:start-end :=多少小时零多少分钟多少秒??????