注册

一抹夏忧、myth8860 达梦巨佬速进,关于日期间隔的问题

马化腾 2022/10/19 1333 21 已解决

为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【DM版本】: DM7
【操作系统】:Linux
【CPU】:
【问题描述】*:

  • sql场景

    • 计算两个日期之间,相差的年份
  • 下面的语句是可以正常执行的,其中注释掉的语句和select后的是一样的,证明这个写法是没问题的

select trunc(months_between(now(), concat(c.birth_date_year, '-', c.birth_date_month, '-01')) / 12) from CADRE_BASIC_INFO c where c.birth_date_year is not null and c.birth_date_year != '' and c.birth_date_month is not null and c.birth_date_month != '' -- and trunc(months_between(now(), concat(c.birth_date_year, '-', c.birth_date_month, '-01')) / 12) > 65

image.png

  • 当我把注释语句打开后,却报(非法的时间日期类型数据)的错误
select trunc(months_between(now(), concat(c.birth_date_year, '-', c.birth_date_month, '-01')) / 12) from CADRE_BASIC_INFO c where c.birth_date_year is not null and c.birth_date_year != '' and c.birth_date_month is not null and c.birth_date_month != '' and trunc(months_between(now(), concat(c.birth_date_year, '-', c.birth_date_month, '-01')) / 12) > 65

image.png

有没有达梦巨佬可以解答下!!!

回答 0
暂无回答
扫一扫
联系客服