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
icturion
Resolver II
Resolver II

Calculate time between two date column in different tables

Hello,

 

I'm trying to calculate the time between two date columns that are in different tables

 

This is what i got so far:

_AN_Houdbaarheid = ('AQZ_TEST_VIEW'[AN_start_Datum] - RELATED(AQZ_SAMP_VIEW[MO_Bemonsteringsdatum]))
 
But is output is incorrect: (see table)

houdbaarheid.JPG

 

For example the time differens in the first record should juist a bit longer than 3 days and not -201,63

 

I also tried: 

_AN_Houdbaarheid = DATEDIFF(RELATED(AQZ_SAMP_VIEW[MO_Bemonsteringsdatum].[Date]);'AQZ_TEST_VIEW'[AN_start_Datum].[Date];DAY)

 

But the same probleem. Hopefully someone can help my

 

 

1 ACCEPTED SOLUTION

Hi @icturion ,

By my tests, if you want to calculate the difference between the date from different table, you formula should be right.

I have a little confused about your scenario, for your first record, the difference between 2016-7-28 11:45:00 and 2016-1-8 20:31:00 should be 202 if you calculate for Days.

Capture.PNG

Why do you think that time differens in the first record should juist a bit longer than 3 days?

Did I misunderstand your data sample?

What is your desired output? And which difference do you want to calculate between the two date column? Day, Month or Minute?

Best Regards,

Cherry

 

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
TomMartens
Super User
Super User

Hey,

 

I guess the date is not recognized properly, just check using the month function, if you receive July or August and not error and January.

Do not use .Day, just the column reference.

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Hi Tom,

 

If i use: 

Month check = AQZ_TEST_VIEW[AN_Start_Datum].[Month] 

and

Month check = AQZ_SAMP_VIEW[MO_bemonsteringdatum].[Month] 

 

I get the correct month on bove columns.

 

but still the time differents is incorrect

Hi @icturion ,

By my tests, if you want to calculate the difference between the date from different table, you formula should be right.

I have a little confused about your scenario, for your first record, the difference between 2016-7-28 11:45:00 and 2016-1-8 20:31:00 should be 202 if you calculate for Days.

Capture.PNG

Why do you think that time differens in the first record should juist a bit longer than 3 days?

Did I misunderstand your data sample?

What is your desired output? And which difference do you want to calculate between the two date column? Day, Month or Minute?

Best Regards,

Cherry

 

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Tom,

 

If I use month with datediff the i get an error.

 

both columns are type: date and time

 

Regards

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.