显示当前年份而不更改其他值。 [英] Showing the current year without changing the other values.
本文介绍了显示当前年份而不更改其他值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
场景就像..
我有专栏quarter_startdate ='''2012-07-01''。
现在我必须写一个更新查询,只需要当前年份,但月份和日期是固定的。
请帮助我
scenario is like..
i have the column quarter_startdate=''2012-07-01''.
Now i have to write an update query which takes only the current year but month and date are fixed.
Pls Help Me
推荐答案
尝试
Try
UPDATE Table_Name
SET quarter_startdate = DATEADD(YEAR, DATEDIFF(YEAR,quarter_startdate,GETDATE()), quarter_startdate)
>
检查这个....
Hi,
Check this....
UPDATE Table_Name SET quarter_startdate=CAST(YEAR(GETDATE()) AS VARCHAR(4))+'-'+
RIGHT('00'+CAST(MONTH(quarter_startdate) AS VARCHAR(2)),2)+'-'+
RIGHT('00'+CAST(DAY(quarter_startdate) AS VARCHAR(2)),2)
-- Try this also
UPDATE Table_Name SET quarter_startdate= DATEADD(YEAR,YEAR(GETDATE())-YEAR(@quarter_startdate),quarter_startdate)
问候,
GVPrabu
Regards,
GVPrabu
这篇关于显示当前年份而不更改其他值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文