如果dtTime是datetime型: Select * from mpKind where convert(varchar(8),dtTime,108)>'18:00:00'
Select * from mpKind where datepart(hour,dtTime)>=18
Select * from mpKind where DATEPART(hour, dtTime) > 18
Select * from mpKind where DATEPART(hour, dtTime) > 18
Select * from mpKind where convert(varchar(8),dtTime,108)>'18:00:00'
Select * from mpKind where convert(varchar(8),dtTime,108)>'18:00:00'就这句可以拉,反正字符串转时间,时间转字符串的函数就用convert,你看看帮助把,有详细解释
create procedure up_mypro ( @date varchar(10) ) as Select * from mpKind where convert(varchar(8),dtTime,108)>'10:00:00' and convert(varchar(10),dtTime,120) = @date go exec up_mypro '2004-08-09'
日期型数据需包含年月日才行。你可以将小时单独提出来 Select * from mpKind where datepart(hh,dtTime) >=18
Select * from mpKind where convert(varchar(8),dtTime,108)>'18:00:00'
(
@date varchar(10)
)
as
Select * from mpKind
where convert(varchar(8),dtTime,108)>'10:00:00'
and convert(varchar(10),dtTime,120) = @date
go
exec up_mypro '2004-08-09'
Select * from mpKind where datepart(hh,dtTime) >=18