日期类型数据是不能 用date like yyyy-mm-dd hh:i:s 这种形式来比较的:--取得月份,然后在比较 select DATEADD(hh,-8,date) from barcode_2d where convert(varchar(7),DATEADD(hh,-8,date),120) = '2013-07'
--試試以下: select DATEADD(hh,-8,date) from barcode_2d where CONVERT(CHAR(7),DATEADD(hh,-8,date),120)='2013-07'
select DATEADD(hh,-8,date)
from barcode_2d
where convert(varchar(7),DATEADD(hh,-8,date),120) = '2013-07'
--試試以下:
select DATEADD(hh,-8,date)
from barcode_2d
where CONVERT(CHAR(7),DATEADD(hh,-8,date),120)='2013-07'