cancel
Showing results for
Did you mean:
Regular Visitor

## 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)

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

Accepted Solutions
Community Support Team

## Re: Calculate time between two date column in different tables

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.

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.
4 REPLIES 4
Super User

## Re: Calculate time between two date column in different tables

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

Hamburg - Germany
If I answer you question, please mark my post as solution, this will also help others.
Proud to be a Datanaut!
Regular Visitor

## Re: Calculate time between two date column in different tables

Hi Tom,

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

both columns are type: date and time

Regards

Regular Visitor

## Re: Calculate time between two date column in different tables

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

Community Support Team

## Re: Calculate time between two date column in different tables

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.

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.