5 Replies Latest reply: Sep 26, 2016 1:04 PM by Sunny Talwar RSS

    How to get Closest Date

    Francisco Lannes

      Hi,

        • Re: How to get Closest Date
          Sunny Talwar

          Hi Francisco -

           

          Do you literally mean the closest date? It could be above or below the dates you have?

          • Re: How to get Closest Date
            Alessandro Furtado

            Hi Francisco.

             

            What you mean with "closest Date"  To Up or Down?

             

            For this

             

            Table1:

            Number     Date1

            1               16/08/2016

             

            you have in table2

             

            Table2:

            Number     Date2             State

            1              10/08/2016             A

            1              14/08/2016             B

            1              20/08/2016             D

            1              28/08/2016             B

             

            and the final was

             

            Final Table:

            Number     Date1           State

            1               16/08/2016          B

             

            To Number 1 and Date1 16/08/2016, the closest (before 16/08/2016) was 14/08/2016 and State B (like you TableFinal)

             

            But, in other hand....

             

            Table1:

            Number     Date1

            1               26/08/2016

             

            Table2:

            Number     Date2             State

            1              10/08/2016             A

            1              14/08/2016             B

            1              20/08/2016             D

            1              28/08/2016             B

             

            Final Table:

            Number     Date1           State

            1               26/08/2016          B

             

            Would be B  or D (20/08/2016 - D)?

             

            I did like this

            Numero DataInicio1 DataInicio2 Estado
            116/08/201614/08/2016B
            121/08/201620/08/2016D
            126/08/201620/08/2016D
            207/08/201605/08/2016C
            216/08/201610/08/2016C
            307/08/201606/08/2016A
            312/08/201606/08/2016A