需要减掉几年,就设getdate()与getdate()的年作比较
比如,今天是07-12-18,我想update ctime栏位到06年,则:
update old set ctime=ctime-datediff(day,'06-12-18',getdate())
本文介绍了一种使用SQL语句更新数据库中日期字段的方法,通过datediff函数结合getdate函数实现将日期字段减去特定年份的功能。
需要减掉几年,就设getdate()与getdate()的年作比较
比如,今天是07-12-18,我想update ctime栏位到06年,则:
update old set ctime=ctime-datediff(day,'06-12-18',getdate())

被折叠的 条评论
为什么被折叠?