BETWEEN cast('2007-10-01 00:00:00' as datetime) AND cast('2007-10-31 23:59:59' as datetime)) 把两段时间摘出来

解决方案 »

  1.   

    这是条sql语句 求两段时间之间的内容 两端时间是变量 我想取出来
      

  2.   

    declare @sql varchar(1000)
    declare @time1 varchar(10)
    declare @time2 varchar(10)Set @sql = 'select * from A where createddate between convert(datetime,''' + @time1 + ''') and convert(datetime,''' + @time2 + ''')'Exec(@sql)
      

  3.   

    string kssj="2007-10-01 00:00:00";
    SQL里 convert(char(10),kssj,120) as datetime
      

  4.   

    我的意思是 我从数据库得到一条sql语句BETWEEN cast( '2007-10-01 00:00:00 ' as datetime) AND cast( '2007-10-31 23:59:59 ' as datetime)) 把两段时间摘出来 我想把两端时间取出来 
    即上面得到的结果是
     str1 = "2007-10-01 00:00:00";
    str2 = "2007-10-31 23:59:59" 
      

  5.   

    LZ要实现的是什么功能??
    开始时间和结束时间的字段不是本来就有?
    直接读出来不可以?
    为什么一定要在
    下面的语句中读??
    BETWEEN cast(  '2007-10-01 00:00:00  ' as datetime) AND cast(  '2007-10-31 23:59:59  ' as datetime))
    很奇怪.............