1.
  select distinct convert(varchar(10),thetime,120)  from 表

解决方案 »

  1.   

    1 取Day用compara比较,或用Substring(0,10)取前面在比较2 Case when then
      

  2.   

    2看不明白,感觉是时间段的问题,参考一下datediff、dateadd等时间函数
      

  3.   

    第二个问题就是:
    比如有一个2005-3-3的超链接,点击进入以后里面应该显示成如下格式id        时间            其他
    1    2005-3-2 15:30:00     ...
    2    2005-3-2 15:31:29     ...
    3    2005-3-2 15:32:32     ...
    .
    .
    n    2005-3-3 15:29:59     ...这些时间段里的时间属于2005-3-3这个日期的。
    求SQL语句,可以实现吗?
      

  4.   

    select *  from 表  where dateadd(dd,1,convert(varchar(10),thetime,120) +' 15:30')<='2005-03-03'  and datediff(mi,convert(varchar(10),thetime,120) +' 15:30','2005-03-03'+' 15:30')>0
      

  5.   

    To:  Softlee81307(孔腎) 
    第2个有些问题,我按照你的运行,结果不对!
      

  6.   

    set  language us_english
    create  table  ppp(id  int,thetime datetime)
    insert into ppp
    select 1 ,      '2005-3-3 16:58:06'   union  all
    select 2 ,      '2005-3-2 12:23:23' union  all
    select 3 ,      '2005-3-3 18:22:31' union  all
    select 4 ,      '2005-3-2 12:06:58' union  all
    select 5 ,      '2005-3-2 11:08:09'  union all
    select 6,   '2005-3-2 15:30:00'    union all
    select 7  ,  '2005-3-2 15:31:29'    union all
    select 8   , '2005-3-2 15:32:32'   union all
    select 9,'2005-3-3 15:29:59'
    ------------------實現語句----------------------
    select *  from ppp  where datediff(mi,thetime,dateadd(dd,-1,'2005-03-03 15:30' )  )<=0
    and datediff(mi,thetime, '2005-03-03 15:30')>0
    --------------結果-----------------------
    6 2005-03-02 15:30:00.000
    7 2005-03-02 15:31:29.000
    8 2005-03-02 15:32:32.000
    9 2005-03-03 15:29:59.000
      

  7.   

    ---如果 2005-03-03 15:30的記錄也要的話則改成 >= 就行
    select *  from ppp  where datediff(mi,thetime,dateadd(dd,-1,'2005-03-03 15:30' )  )<=0
    and datediff(mi,thetime, '2005-03-03 15:30')>=0