Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

Adding integer value to datetime in SQL

$
0
0

Hi,

I am trying to add integer value to the datetime to get the configurable "date".

But it is not working out. Here is the code for it.

declare @Id int;
exec @Id = up_GetConfigurableDayInterval
print getdate() + @Id

The sp "up_GetConfigurableDayInterval", will return number of days to add the the current date time. 

But print getdate() + @Id , is not producing the updated result.

But when ever i have replaced the variable "@Id" with a value, Say "5", it is producing the expected result.

I have also tested the above code by the following:-

create table Temp(value datetime);
insert into Temp values(getdate() + @Id);
select * from Temp

But it is not having the new added datetime.

May i know, how to get it.

Thanks in advance.


NANDAKUMAR.T


Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>