当前位置: 代码迷 >> Sql Server >> 关于单数日期查询的有关问题
  详细解决方案

关于单数日期查询的有关问题

热度:135   发布时间:2016-04-27 21:46:12.0
关于单数日期查询的问题
数据库中的每天都录入数据,其中有日期字段

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



------解决方案--------------------
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
  相关解决方案