获取一年中截止到当月的数据(包括当月的数据和今年当月之前的数据)
数据类型是varchar类型

微信截图_20220627200708.png

FineReport 余悸 发布于 2022-6-27 20:09 (编辑于 2022-6-27 20:09)
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共3回答
最佳回答
0
finereadLv6初级互助
发布于2022-6-27 20:12

oracle数据库,获取当前月https://www.cnblogs.com/webttt/p/7803830.html

select  to_char(sysdate, 'MM' )-1  from dual

  • 余悸 余悸(提问者) SQL server数据库 而且日期都是用varchar类型
    2022-06-27 20:21 
  • fineread fineread 回复 余悸(提问者) 哦哦,sqlserver数据库这样好像就可以了,日期字段<=substring(convert(varchar(12),getdate(),23),1,7)
    2022-06-27 20:32 
最佳回答
0
CD20160914Lv8专家互助
发布于2022-6-27 21:09

select * from 表名称

where year ='2022'

and month<='06'

如果是参数的话

select * from 表名称

where year ='${year_code}'

and month<='${month_code}'

最佳回答
0
蒲公英FZLJLv5初级互助
发布于2022-6-27 22:07

1、当月

year*100+month=datepart(year,getdate())*100+datepart(month,getdate())

2、今年当月之前

year=datepart(year,getdate()) and month<datepart(month,getdate())

  • 4关注人数
  • 405浏览人数
  • 最后回答于:2022-6-27 22:07
    请选择关闭问题的原因
    确定 取消
    返回顶部