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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
hans3400
Helper I
Helper I

Difference between two dates (power query)

Hi

 

I want to make a column with difference between two date colums. I know i can use =duration.days(date1-date2), but the thing is that one of my date colums also contains time. When I enter in the function the new columns returns with an error. 

 

Can I do something so the function only calculate the difference between the dates and ignores the time in one of the columns?

2 ACCEPTED SOLUTIONS
Bifinity_75
Solution Sage
Solution Sage

Hi @hans3400 , insert a custom column, and write this formule:

[Date 2]-Date.From([Date 1])

When Date 1 y the date with hours, and Date 2 is the normal date (without hours).

 

The result:

Bifinity_75_0-1668085841144.png

 

Best regards

View solution in original post

AntrikshSharma
Super User
Super User

@hans3400 Use Date.From on the datetime column

 

Duration.Days ( Date.From ( [date1] ) - [date2] )

View solution in original post

2 REPLIES 2
AntrikshSharma
Super User
Super User

@hans3400 Use Date.From on the datetime column

 

Duration.Days ( Date.From ( [date1] ) - [date2] )

Bifinity_75
Solution Sage
Solution Sage

Hi @hans3400 , insert a custom column, and write this formule:

[Date 2]-Date.From([Date 1])

When Date 1 y the date with hours, and Date 2 is the normal date (without hours).

 

The result:

Bifinity_75_0-1668085841144.png

 

Best regards

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.