select * from talbe where col between '2007-1-1 10:00:00' and '2009-4-18 12:00:00'
select * from tb where cast(DATETMP+' '+TIMETM as datetime) between '2007-1-1' and '2009-4-18'
select * from tb where cast(DATETMP+' '+TIMETM as datetime) between '2007-1-1 10:00:00' and '2009-4-18 12:00:00'改正.
两种写法: 方法一: 1.select * from tab where DATETIME between '2007-1-1 10:00:00' and '2009-4-18 12:00:00'方法二: 2、select * from tab where DATETIME>'2007-1-1 10:00:00' and DATETIME<'2009-4-18 12:00:00'
大家理解错了, 我的意思是日期时间分别是两个字段 我下面语句写得不对,就是那个意思. select * from tab where DATETMP>'2007-1-1' and TIMETMP< 12:00:00'
select * from tb where cast(DATETMP+' '+TIMETM as datetime) between '2007-1-1 10:00:00' and '2009-4-18 12:00:00'
楼主以下是不是你想要的结果 select * from tab where DATETIME between '2007-1-1 10:00:00' and '2009-4-18 12:00:00' union select * from tab where TIMETMP between '2007-1-1 10:00:00' and '2009-4-18 12:00:00'
select * from talbe where col between '2007-1-1 10:00:00' and '2009-4-18 12:00:00'
from tb
where cast(DATETMP+' '+TIMETM as datetime) between '2007-1-1' and '2009-4-18'
from tb
where cast(DATETMP+' '+TIMETM as datetime) between '2007-1-1 10:00:00' and '2009-4-18 12:00:00'改正.
方法一:
1.select * from tab where DATETIME between '2007-1-1 10:00:00' and '2009-4-18 12:00:00'方法二:
2、select * from tab where DATETIME>'2007-1-1 10:00:00' and DATETIME<'2009-4-18 12:00:00'
我下面语句写得不对,就是那个意思.
select * from tab where DATETMP>'2007-1-1' and TIMETMP< 12:00:00'
where cast(DATETMP+' '+TIMETM as datetime) between '2007-1-1 10:00:00' and '2009-4-18 12:00:00'
楼主以下是不是你想要的结果
select * from tab where DATETIME between '2007-1-1 10:00:00' and '2009-4-18 12:00:00'
union
select * from tab where TIMETMP between '2007-1-1 10:00:00' and '2009-4-18 12:00:00'