ASPForums.Net RSS Feed additions to the content that appears on ASPForums.Net(c) 2019 All rights reserved.Query to add Year to DateTime in SQL Server<p>Hi&nbsp;PRA,</p> <blockquote><cite>PRA says:</cite> <pre><code class="sql plain">print DATEADD(</code><code class="sql color2">year</code><code class="sql plain">, 1, @</code><code class="sql keyword">date</code><code class="sql plain">)</code></pre> </blockquote> <p>You need to pass&nbsp;@num instead of 1.</p> <p>Refer below sample query.</p> <p><strong><span style="text-decoration: underline;">SQL</span></strong></p> <pre class="brush: sql">declare @num int, @date date, @res int set @date = &#39;2017-04-14&#39; set @res = CONVERT(VARCHAR,CONVERT(INT,DATEDIFF(DD,@date,GETDATE())/365.25)) set @num = 0 while(@num &lt;= @res) begin if(@num = 0) BEGIN print @date END else if(@num &gt; 0) BEGIN print DATEADD(year, @num, @date) END set @num = @num + 1 end</pre> <p><strong><span style="text-decoration: underline;">Output</span></strong></p> <p>2017-04-14</p> <p>2018-04-14</p> <p>2019-04-14</p>, 15 Apr 2019 06:07:08 GMT