查询

lchljj 2003-10-09 08:57:57
表:

序号 建厂日期
1 2001-01-05
2 2002-01-01
3 2002-03-06
4 2003-05-09
5 2003-08-04

select 建厂日期 from 表名 where 建厂日期 like '% 2002( year(getdate())-1) %'怎样实现括号中的写法(我每次查询的是上一年的建厂日期)。
...全文
30 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
zarge 2003-10-09
  • 打赏
  • 举报
回复
select 建厂日期 from 表名 where year(建厂日期) = year(getdate()) - 1
伍子V5 2003-10-09
  • 打赏
  • 举报
回复
select 建厂日期 from 表名 where datepart(y,建厂日期)=year(getdate())-1
txlicenhe 2003-10-09
  • 打赏
  • 举报
回复
select 建厂日期 from 表名 where year(建厂日期) = year(getdate()) - 1
pengdali 2003-10-09
  • 打赏
  • 举报
回复
或:
select 建厂日期 from 表名 where year(建厂日期)=year(getdate())-1
pengdali 2003-10-09
  • 打赏
  • 举报
回复
select 建厂日期 from 表名 where datediff(year,建厂日期,getdate())=1

34,576

社区成员

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

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