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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Bharani
Regular Visitor

Find time duration between 2 dates (Datetime format)

Hi Experts - Am new to Power BI.. Hope u can crack my query in a min...

 

I need to calculate "Number of minutes" between 2 dates which is in Datetime format..Below date is an example..

 

3/11/2014  10:57:06 AM

 

i have 2 coulmns in my data as shown below.. Please help me in adding a new column in data which shows the difference between accept time & logtime from below screenshot.. it should show me in minutes..

 

For Eg, for the first one.. from below data it should show as 19 Mins

 

Capture.JPG

 

 

8 REPLIES 8
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Bharani,

 

You could try with the dax formula below to create the calculate column.

 

diff =
VAR tem = 'CountMinutes'[accepttime] - 'CountMinutes'[logtime]
RETURN
    HOUR ( tem ) * 60
        + MINUTE ( tem )

Then you will  get the output below.

 

Find time duration between 2 dates.PNG

 

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.

By the way, i get the error..

 

Capture.JPG

Hi @Bharani,

 

Have you solved your problem?

 

If you have solved, please always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.

 

If you still need help, please feel free to ask.

 

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 @Bharani,

 

Do you create the calculated column with the fomula?

 

Could you show the detail error message? 

 

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.

Thanks!! Does it work if logtime and accepttime are on different days, months or years?

Johanno
Continued Contributor
Continued Contributor

Nice! However, that won't work when the logtime and accepttime are on different days, months or years?

Hi @Johanno @Bharani,

 

Try this formula below.

 

Time = 
VAR DIFF = 'CountMinutes'[accepttime] - 'CountMinutes'[logtime]
VAR NumOfMinutes = DIFF * 24
    * 60
VAR DAYS =
    IF ( DIFF >= 1, INT ( DIFF ), BLANK () )
VAR HOURS =
    INT ( ( DIFF - DAYS ) * 24 )
VAR MINUTES = NumOfMinutes
    - ( DAYS * 24
    * 60 )
    - ( HOURS * 60 ) 
RETURN
    DAYS*24*60+HOURS*60+MINUTES

Here is the output.

 

Capture.PNG

 

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.
Johanno
Continued Contributor
Continued Contributor

Hi, an ugly solution could be as a measure where I called my table CountMinutes:

CountMinutes = SUMX(CountMinutes;
YEAR(CountMinutes[accepttime])*1440*365+MONTH(CountMinutes[accepttime])*1440*30+DAY(CountMinutes[accepttime])*1440+HOUR(CountMinutes[accepttime])*60+MINUTE(CountMinutes[accepttime])
-YEAR(CountMinutes[logtime])*1440*365-MONTH(CountMinutes[logtime])*1440*30-DAY(CountMinutes[logtime])*1440-HOUR(CountMinutes[logtime])*60-MINUTE(CountMinutes[logtime]))

Someone will probably give us a more sophisticated solution. Smiley Very Happy

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.