I am trying to get the number of days,month and year from 2dates, but those are getting individual
DECLARE @datecount INT;
DECLARE @monthcount INT;
DECLARE @yearcount INT;
SELECT @datecount = (SELECT DATEDIFF(DAY, usr.registrationdate, GETDATE())
FROM users usr
WHERE usr.userid = @UserId);
SELECT @monthcount = (SELECT DATEDIFF(MONTH, usr.registrationdate, GETDATE())
FROM users usr
WHERE usr.userid = @UserId);
SELECT @yearcount = (SELECT DATEDIFF(YEAR, usr.registrationdate, GETDATE())
FROM users usr
WHERE usr.userid = @UserId);
How to cast these 3 variables? Or how can I get this in one step?
no. of days / no. of months / no. of year
What I want the output is = 3:1:2
or 3 days / 1 month / 4 years