Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (6.1k points)

I am attempting to add days to the current date and it's working fine however when I add 360 days to the current date it is giving me the wrong value.

Eg: Current Date is 11/12/2020

And I am adding 360 Days to it, it should give me 11/12/2021, though it is displaying the same date 11/12/2020. the year is not changing.

Here is my code:

select dateadd(dd,360,getdate())

1 Answer

0 votes
by (12.7k points)

You can use like this:

Select (Getdate()+360) As MyDate

There is no need to use the dateadd function for adding or subtracting days from the given date. For adding years, months, hours you require the dateadd function.

Want to know more about SQL? Join this SQL Course by Intellipaat.

Related questions

0 votes
1 answer
asked Jan 31, 2020 in BI by Vaibhav Ameta (17.6k points)
0 votes
2 answers
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...