Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Compare Dates

Hi,

Why is this giving correct results?

Column INT = IF(Table1[Column1].[Date] > Table1[Column2].[Date], 0, 1)


And this is not?

Column DIFF = IF(Table1[Column1].[Date] > Table1[Column2].[Date], DATEDIFF(Table1[Column3].[Date], Table1[Column1].[Date],DAY), DATEDIFF(Table1[Column3].[Date], Table1[Column2].[Date],DAY))
 
 

  • Hello,

     

    It does give the correct result in both cases.

     

    Why it might seem it is not correct is because as you wrote your formula for Column DIFF in your sample data you compare the same dates 1/1/2020 with 02/20/2019, on both rows, so you get the same -315 result

     

    Regards,

    ElenaN

2 Replies

  • Hello,

     

    It does give the correct result in both cases.

     

    Why it might seem it is not correct is because as you wrote your formula for Column DIFF in your sample data you compare the same dates 1/1/2020 with 02/20/2019, on both rows, so you get the same -315 result

     

    Regards,

    ElenaN

    • Anonymous's avatar
      Anonymous
      Not applicable

      :smileyfrustrated:

      uh!
      Silly me...

       

      Cheers!