求一SQL语句写法

StudyHard2002 2003-11-27 09:53:03
请教各位,比如录入记录时写入当前录入日期,如果我想查询一个月之内的记录,SQL语句该如何写?
...全文
38 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
btlxy 2003-11-27
  • 打赏
  • 举报
回复
对不起:
select * from 表 where CONVERT(char(6),时间,112)=convert(char(6),getdate(),112)

btlxy 2003-11-27
  • 打赏
  • 举报
回复
select * from 表 where CONVERT(char(6),时间,120)=convert(char(6),getdate(),112)
txlicenhe 2003-11-27
  • 打赏
  • 举报
回复
select * from 表 where dateadd(month,1,录入日期)>= getdate()
pengdali 2003-11-27
  • 打赏
  • 举报
回复
select CONVERT(varchar(10), getDate(),120) --不要时间2002-1-1
select convert(char(8),getdate(),112) ----20020101
select convert(char(8),getdate(),108) ---06:05:05

你的:

select * from 表 where CONVERT(char(7),时间,120)='2003-10'

34,874

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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