question

sergiord2017 avatar image
sergiord2017 asked

datediff

hello , I am working on a piece of code which is treating dyalisis patients treatments. All of these patients have a starting treatment date and some of them have an ending treatment date. Those who don'thave an ending date is because the are still on treatment so we will take the present date (getdate()). These could be a example of the database: START END DIFF IN MONTHS 05/03/2013 05/01/2015 22 28/05/2012 06/06/2017 61 21/08/2016 21/03/2018 19 My question is about how to calculate the difference in months for each year , for example in the first case the 22 months are 9 from 2013 , 12 from 2014 and 1 from 2015. I need the three results... Thanks in advance.
sqldatediff
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Usman Butt avatar image Usman Butt commented ·
@sergiord2017 I have already answered kind of same [question][1] for you. It would be good for you if you come up with the solution for this question yourself. It should be very easy once you understand the solution already provided. [1]: https://ask.sqlservercentral.com/questions/146652/transform-one-record-into-several-records-with-dat.html#answer-146653
0 Likes 0 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.