显示当前年份而不更改其他值。 [英] Displaying the current year without changing the other values.
本文介绍了显示当前年份而不更改其他值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望显示以下日期值替换当年与下一年。
2012-07-01必须更改为2013-07-01。
这里一年只有一部分需要更改但不是日期和月份
请帮助
I wanted to display following date value replacing current year with the next year.
2012-07-01 must be changed to 2013-07-01.
Here year part alone to be changed but not the date and month
Pls I need help
推荐答案
使用 DateAdd [ ^ 具有年
作为Datepart
参数。
Use DateAdd[^] withyear
as theDatepart
parameter.
DateAdd(year,1,YourDateColumnName)
要将现有日期更改为下一年,同时保持月和日相同:
To change an existing date to the next year while keeping the month and day the same:
UPDATE yourtablename SET quarter_startdate=DATEADD(year,1,quarter_startdate);
如果它是你想要的显示:
If it is display that you want:
SELECT
DateAdd(year,1,TableName.dateColumnName) AS [YearAddedDate]
FROM
TableName
如果你想更新表格或添加标准,显然你需要修改。更明显的是,您需要为斜体名称提供正确的值。
这篇关于显示当前年份而不更改其他值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文