Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
bsaldri1028
New Member

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, QUARTER, MONTH, WEEK, DAY, HOUR, MINUTE, SECOND."

 

Previously it was giving me this error:

"The syntax for 'TODAY' is incorrect. (DAX(Datediff([sys_created_on].[Day]TODAY()))).

 

OR most frequently

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

 

Each time I try to include DATEDIFF option - current one is 

Age = Datediff(TODAY(),[sys_created_on].[Day])
1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @bsaldri1028 ,

 

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


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

1 REPLY 1
MFelix
Super User
Super User

Hi @bsaldri1028 ,

 

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


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.