6 Replies Latest reply on Mar 21, 2018 1:44 PM by Deepak Rai

    How to create a date difference within a row and within multiple years

    Neishay Ayub

      Hello,

       

      I am have difficultly with date difference. I am trying to calculate the difference in Year for each patient ID, to do a larger Kaplan Meier Curve Analysis. For each ID, A/B/C, I want a column that tells me how much time passes from the first year of their event.

       

      Screen Shot 2018-03-21 at 3.03.53 PM.png

      So Ideally a Time passed column would be:

      Unlinked ID.     Year of Event               Time Passed

      A                    2010                                  0

                            2011                                   1 year

                            2012                                   2

                            2014                                   4

       

      B               2007                                       0

                       2008                                        1

                       2010                                        3

       

      C               2012                                        0

                        2013                                        1

                        2014                                        2

                        2015                                        3

                        2016                                        4

                        2017                                        5

                    

       

       

      I was trying to create a calculated field, such as "{FIXED([Unlinked ID], DATEPART('year',[Date Time]):DATEDIFF()", but I was not sure how to best code this.

       

      Thanks for your help!

       

      Neishay