Forum Discussion

moutinhoabreu's avatar
moutinhoabreu
Frequent Visitor
7 years ago
Solved

DATEDIFF, calculate days between today and SQL date field, error

Hi All,

 

I had a new column with the DATEDIFF working fine and suddendly stoped working.

 

Age = DATEDIFF(utcnow()+ 'Contas correntes de clientes'[dataven]+ DAY)

 

I was calculating the number of days between today and a sql column date with a previous date.

 

Now i have this error:

Too few arguments were passed to the DATEDIFF function. The minimum argument count for the function is 3.

  • Greg_Deckler's avatar
    Greg_Deckler
    7 years ago

    Seems like this should be the one:

     

    Age = DATEDIFF(UTCTODAY(), 'Contas correntes de clientes'[dataven], DAY)

     

    Is this a column or a measure?

     

    This is what worked for me in a standard Calendar table:

     

    Column = DATEDIFF(UTCTODAY(), [Date], DAY)

     

5 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    It seems like you have plus symbols (+) where you should have commas (,) or semi-colons (;). 

     

    I am unaware of a regional language variation that uses + symbols like that...

    • moutinhoabreu's avatar
      moutinhoabreu
      Frequent Visitor

      I've tried with this both syntax:

       

      Age = DATEDIFF(UTCTODAY(); 'Contas correntes de clientes'[dataven]; DAY)

       

      and 

       

      Age = DATEDIFF(UTCTODAY(), 'Contas correntes de clientes'[dataven], DAY)

       

      And the error now is:

       

      The syntax for ';' is incorrect. (DAX(DATEDIFF(UTCTODAY(); 'Contas correntes de clientes'[dataven]; DAY))).

      • Greg_Deckler's avatar
        Greg_Deckler
        Icon for Community Champion rankCommunity Champion

        Seems like this should be the one:

         

        Age = DATEDIFF(UTCTODAY(), 'Contas correntes de clientes'[dataven], DAY)

         

        Is this a column or a measure?

         

        This is what worked for me in a standard Calendar table:

         

        Column = DATEDIFF(UTCTODAY(), [Date], DAY)