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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
g_hill
Frequent Visitor

How to calculate number of days between two date fields

Hello,

 

I'm trying to set up a new measure to calculate number of days between two date fields in the same table. I've tried using the DATESBETWEEN DAX function but it doesn't work for me.

The start date field is called Close Date and the end date is called Let Date. They're both in a table called CBLShortlists. I've tried the following but it doesn't recognise the field names:

Days to Let = DATESBETWEEN(CBLShortlists,Close Date,Let Date)
 
Can anyone suggest a way to work this out?
 
Thanks in advance

 

1 ACCEPTED SOLUTION
Samarth_18
Community Champion
Community Champion

Hi @g_hill 

You can try below code:-

 

Days to Let = DATEDIFF(Close Date,Let Date,day)

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

2 REPLIES 2
Samarth_18
Community Champion
Community Champion

Hi @g_hill 

You can try below code:-

 

Days to Let = DATEDIFF(Close Date,Let Date,day)

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

This is the way. You can just subtract days (i.e. LetDate - CloseDate) since they are stored as the number of days since 12/30/1899 but DATEDIFF is more flexible and can easily handle other units too (SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, YEAR).

 

@g_hill The DATESBETWEEN function is for Time Intelligence and returns a table of date values between two dates rather than a single number. It's generally used for filtering.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors