查询时用到的日期比较,万分急!

ydxiaojun 2017-07-30 11:28:12
表里其字一字段dztime为日期比如:2017-7-7
现在要查询当前年月和字段里面的年月做比对。
dztime<>2017-7
因为是新手:
1、字段dztime如何变成2017-7
2、如何做比较
...全文
432 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
学习a123456 2018-04-02
  • 打赏
  • 举报
回复
datediiff挺可靠,我网站上就有个删除久于多少天的文章。。。这样一个应用
ysf0181 2017-08-03
  • 打赏
  • 举报
回复
ACCESS: checktime between '#2011-06-20#' and '#2011-06-30#' SQL: checktime between '2011-06-20' and '2011-06-30'
c1s2d3n40 2017-08-01
  • 打赏
  • 举报
回复
如果只是不叫时间是的话可以试试 datediiff 。
Go 旅城通票 2017-08-01
  • 打赏
  • 举报
回复
datepart要直接操作数据库,而不是放到vbs里面 conn.execute("delete * from tb_article where dztime is not null and replace(str(datepart(""yyyy"",dztime))+'-'+str(datepart(""m"",dztime)),' ','')<"&year(date())&"&-"&month(date())&" ")
ydxiaojun 2017-07-30
  • 打赏
  • 举报
回复
提示dztime 类型不匹配
ydxiaojun 2017-07-30
  • 打赏
  • 举报
回复
if request("action")="del_yydz" then if session("users_s")=1 then conn.execute("delete * from tb_article where dztime is not null and "&datepart("yyyy","dztime")&"&-"&datepart("m","dztime")&"<"&year(date())&"&-"&month(date())&" ") Response.Write "<script language='javascript'>alert('数据删除成功!);window.location.href('/index.asp');</script>" else Response.redirect("/index.asp") end if end if

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧