How To Add Days To The Current Date?
I am trying to add days to the current date and it's working fine but when I add 360 days to the current date it gives me wrong value. eg: Current Date is 11/04/2014 And I am addin
Solution 1:
Just do-
Select (Getdate()+360) As MyDate
There is no need to use dateadd function for adding or subtracting days from a given date. For adding years, months, hours you need the dateadd function.
Solution 2:
select dateadd(dd,360,getdate()) will give you correct date as shown below:
2017-09-30 15:40:37.260
I just ran the query and checked:

Solution 3:
Dateadd(datepart,number,date)
You should use it like this:
select DATEADD(day,360,getdate())
Then you will find the same date but different year.
Solution 4:
From the SQL Server 2017 official documentation:
SELECT DATEADD(day, 360, GETDATE());
If you would like to remove the time part of the GETDATE function, you can do:
SELECT DATEADD(day, 360, CAST(GETDATE() ASDATE));
Solution 5:
can try this
select (CONVERT(VARCHAR(10),GETDATE()+360,110)) as Date_Result
Post a Comment for "How To Add Days To The Current Date?"