我想判ptime>=18 and ptime<=2359
大家好:
select * from punc_oridata where personcode='C00612' and ptime>='2012-09-19 18:00:00.000'
and ptime<='2012-09-19 23:59:00.000'
我想判ptime>=18 and ptime<=2359
要怎?
.
[解决办法]
- SQL code
select * from punc_oridata where personcode='C00612' and convert(varchar(10),ptime,108) between '18:00:00' and '23:59:59';
[解决办法]
- SQL code
select * from punc_oridata where personcode='C00612' and ptime>='2012-09-19 18:00:00'and ptime<'2012-09-20 00:00:00'
[解决办法]
- SQL code
select * from punc_oridata where personcode='C00612' and datediff(hh,convert(varchar(10),ptime,120),ptime)>=18
[解决办法]
这个是获取小时加分钟:SELECT CONVERT(VARCHAR(2),DATEPART(hh,'2012-09-19 18:00:00.000'))+':'+CONVERT(VARCHAR(2),DATEPART(n,'2012-09-19 18:00:00.000'))