MySQL 插入date 只需年月

MySQL 插入date 只需年月,第1张

首先,date字段不能是日期格式,可以是char,或是int/numeric

以int/numeric为例:可以这样获取年月,格式为201004

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

如果是char可以转换

select convert(char(6),datepart(year,getdate())*100+datepart(month,getdate()))

update tianTable set endTime = date_add(month,1,curdate()) where newsTitle = 'xxx'

update tianTable set endTime=DATEADD(MONTH,1,GETDATE()) where newsTitle = 'xxx'


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/8554761.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-17
下一篇2023-04-17

发表评论

登录后才能评论

评论列表(0条)

    保存