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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Days Presents between two Dates- Power Query

Hi Experts

 

I am trying to work out the number days a certain individual | person had consent for between two dates in Power Query... 

My Start Date is in the format (capture_day_id)
20190101 - i cannot change the date to format 01/01/19

My End Date is in the format (expiration_day_id)
20193101 - i cannot change the date to format 31/01/19


List.Dates(
[capture_day_id],
Duration.Days([capture_day_id] - [expiration_day_id]),
#duration(1, 0, 0, 0)
)

 

But i am getting an error

Invesco_0-1660808621030.png

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Try this for Duration.Days part of your code

 

Duration.Days(
#date(Number.FromText(Text.Start([capture_day_id],4)), Number.FromText(Text.Middle([capture_day_id],4,2)),Number.FromText(Text.End([capture_day_id],2)))
,
#date(Number.FromText(Text.Start([expiration_day_id],4)), Number.FromText(Text.Middle([expiration_day_id],4,2)),Number.FromText(Text.End([expiration_day_id],2)))
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , Try this for Duration.Days part of your code

 

Duration.Days(
#date(Number.FromText(Text.Start([capture_day_id],4)), Number.FromText(Text.Middle([capture_day_id],4,2)),Number.FromText(Text.End([capture_day_id],2)))
,
#date(Number.FromText(Text.Start([expiration_day_id],4)), Number.FromText(Text.Middle([expiration_day_id],4,2)),Number.FromText(Text.End([expiration_day_id],2)))
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi Amit - getting the following error..

Invesco_0-1660810475838.png

 

List.Dates(
[capture_day_id],Duration.Days(
#date(Number.FromText(Text.Start([capture_day_id],4)), Number.FromText(Text.Middle([capture_day_id],4,2)),Number.FromText(Text.End([capture_day_id],2)))
,
#date(Number.FromText(Text.Start([expiration_day_id],4)), Number.FromText(Text.Middle([expiration_day_id],4,2)),Number.FromText(Text.End([expiration_day_id],2)))
),

#duration(1, 0, 0, 0))

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.