日期:2014-05-19  浏览次数:20699 次

关于单数日期查询的问题
数据库中的每天都录入数据,其中有日期字段

如何查询所有单数日期录入的数据



------解决方案--------------------
day(date)% 2 = '0 '
------解决方案--------------------
楼上应该不要引号吧?
------解决方案--------------------
day(datecolumn)%2 = 1
------解决方案--------------------

create table tablen([day] datetime,value varchar(20))
insert into tablen select '2007-1-1 ',1
union all select '2007-1-2 ',1
union all select '2007-1-3 ',2
union all select '2007-1-4 ',3
union all select '2007-1-5 ',4
union all select '2007-1-6 ',5
union all select '2007-1-7 ',6
union all select '2007-1-8 ',7
union all select '2007-1-9 ',8
union all select '2007-2-10 ',210
go

select * from tablen where day([day])%2=1