Reputation: 1
I am trying to make the result for datediff
(interval result) in date format.
I have a view that had columns with numbers, and the other view contains the today date value.
I want to make a date diff between these 2 values, and get the results as a date too.
For example: result 10 for 2018/12/31
and 2018/12/21
.
The date format is: YYYY,MM,DD
Upvotes: 0
Views: 201
Reputation: 5653
If you want to add number of date to given date then you can use the below query.
SELECT CONVERT(varchar(10), DATEADD(DD, 10, '2018-12-21'), 23) AS DateAfterAdd;
--or
SELECT Cast(CONVERT(varchar(10), DATEADD(DD, 10, '2018-12-21'), 23) as Date) AS DateAfterAdd;
The output is as shown below
DateAfterAdd
2018-12-31
Upvotes: 0