Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Datediff

Trying to get number of days between 2 dates - have done multiple different options and DATEDIFF is  giving me these errors:   "The third argument Interval can only be one of the following: YEAR, Q...
  • MFelix's avatar
    6 years ago

    Hi Anonymous ,

     

    Assuming you are making a calculated column your syntax needs to be the following:

     

    Column = DATEDIFF(Table[sys_created_on].[Day]; TODAY();DAY)

     

    Regarding the errors you are having is refering to the fact that you don't have the third parameter on the DATEDIFF function on the option above the calculation is made in days however if you make that parameter  in any of those refered (YEAR, QUARTER, MONTH, WEEK, DAY, HOUR, MINUTE, SECOND) the result will be accordingly to that. 

     

    Another thing is date you are placing the .[day] when refering to your column that will give you a calculation based on the day of the date and not the all date giving you and unexpected result.

     

    If you are refering to a measure your syntax need to be similar to this:

    Measure = DATEDIFF(SELECTEDVALUE('Table'[sys_created_on]); TODAY(); DAY)

     

    Regards,

    MFelix