日期:2014-05-18  浏览次数:20748 次

如何表示

表A,
有一字段为endtime,
endtime的值“2007-5-22   8:00:00”属于datetime类型的,

select   *   from   A   where   endtime=???
问号就是填上当天日期     +     早上八点,
请问如何表示

------解决方案--------------------
select * from A
where endtime = convert(varchar(11),getdate(),120) + '8:00:00 '
------解决方案--------------------
--用convert转换一下


select *
from 表名
where convert(varchar(20),endtime,120) = convert(varchar(10),getdate(),120) + ' 08:00:00 '

------解决方案--------------------
表A,
有一字段为endtime,
endtime的值“2007-5-22 8:00:00”属于datetime类型的,

select * from A where endtime=???
问号就是填上当天日期 + 早上八点,
请问如何表示

select * from A where convert(varchar(10),getdate(),120) + ' 08:00:00 '
------解决方案--------------------
select *
from 表名
where convert(varchar(20),endtime,120) = convert(varchar(10),getdate(),120) + ' 08:00:00 '
------解决方案--------------------
try:
DECLARE @Time nchar(5)
SET @Time= '08:00 '
SELECT * FROM A WHERE CONVERT(nchar(16),endtime,120)=CONVERT(nchar(11),GETDATE(),120)+@Time
------解决方案--------------------
select * from A where endtime=dateadd(hh,8,getdate())