sql中关于有效期的问题,请邹建及各位老大帮看看(100相送) starTime,endTime,sqTime,有效期,这几个时间是什么关系?“从sqTime时间开始20天内”,到什么时候算是20天内? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 表:(分别为开始时间,结束时间,申请时间)starTime,endTime,sqTime 的关系是什么? select * from 表where --在从sqTime时间开始20天内的信息 sqTime>=dateadd(day,-20,getdate) or --在有效期内的记录 getdate() between starTime and endTime 申请时间,是用户发布信息时间,开始时间,结束时间是指管理员批准有时间.说白了就是付费的有效期.如果用户没付费,也可以显示20天.如:id starTime,endTime,sqTime1 null null 2004-11-12 2004-9-1 2005-12-1 2004-8-13 null null 2004-10-1今天的显示的结果为:12 select * from 表 where ( getDate() between starTime and endTime ) or ( starTime is null and endTime is null and getDate()>= dateadd(day,20,sqTime) ) 我写的你必须确保数据中不会出现:starTime 与 endTime 不同时为空 的情况才可以 select * from 表 where starttime is null and sqtime+20>getdate() or starttime is not null and getdate<endtime 更正:select * from 表 where (starttime is null and sqtime+20>getdate()) or (starttime is not null and getdate() between starttime and endtime) zjcxc(邹建) 老大就是宋代的及时雨宋江,就是60年代的雷锋,就是21世纪的,,,,哈哈,谢谢各位.我一会结贴,结贴看看怎么给分才好.谢谢各位 select * from table where datediff(day,sqtime,getdate())<=20 or getdate() between startime and endtime 对于表输入信息的问题? 查询某个库下的所有表名 如何根据一个字段的排序来递增写入一个字段 数据库迁移问题 夜深人静,可以产生冥想,可还有一个语句想不出来!能否帮帮我! 问个最基础的问题,关于SQLSERVER2005 配置连接 还是http://expert.csdn.net/Expert/topic/2429/2429710.xml?100分 求一个复杂的sql语句 ###请进来帮我看看这个问题,是什么原因造成的,关于数据导入的! 我想数据库中新增一条记录通知前台的程序显示,请问如何实现 如果数据库日志很大,是否影响速度?欢迎大家讨论,UP有分 求救,帮忙看看这个sql为什么不能用
表:(分别为开始时间,结束时间,申请时间)starTime,endTime,sqTime
的关系是什么?
where
--在从sqTime时间开始20天内的信息
sqTime>=dateadd(day,-20,getdate)
or --在有效期内的记录
getdate() between starTime and endTime
如果用户没付费,也可以显示20天.如:id starTime,endTime,sqTime1 null null 2004-11-12 2004-9-1 2005-12-1 2004-8-13 null null 2004-10-1今天的显示的结果为:1
2
from 表
where ( getDate() between starTime
and endTime
)
or ( starTime is null
and endTime is null
and getDate()>= dateadd(day,20,sqTime)
)