Here is what i have:
,CAST(DATEDIFF(month, a.LstPaymentDte, a.createdte)/12 as DECIMAL(10, 1)) AS diff_in_month
for example last pay date = 6/14/2019 and createte = today.
I want to see the value return as 1.1 for 1 year and 1 month ago.
Here is what i have:
,CAST(DATEDIFF(month, a.LstPaymentDte, a.createdte)/12 as DECIMAL(10, 1)) AS diff_in_month
for example last pay date = 6/14/2019 and createte = today.
I want to see the value return as 1.1 for 1 year and 1 month ago.
You can use below query. for your desired results.
SELECT cast(DATEDIFF(MONTH,a.LstPaymentDte,a.createdte)/12 AS varchar) + ' Year(s) '+ cast(DATEDIFF(MONTH,a.LstPaymentDte,a.createdte)%12 AS varchar) + ' month(s)' or for 1.1 format SELECT cast(DATEDIFF(MONTH,a.LstPaymentDte,a.createdte)/12 AS varchar) + '.'+ cast(DATEDIFF(MONTH,a.LstPaymentDte,a.createdte)%12 AS varchar)
17 People are following this question.