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

Power Query Error with Specific Date

Hi,

 

I'm getting an error with the below script and I can't see why its comming up. Can anyone please correct me on this?

 

if TERMINATION DATE = 31/12/4721 then

Duration.Days(Date.From(DateTime.LocalNow()) - [CONTINUOUS SERVICE DATE]) /12)

else

Duration.Days([TERMINATION DATE]-[CONTINUOUS SERVICE DATE])/12)

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Update, solved it myself as below

if [TERMINATION DATE] = #date(4721, 12, 31) then

Duration.Days(Date.From(DateTime.LocalNow()) - [CONTINUOUS SERVICE DATE]) /12

else

Duration.Days([TERMINATION DATE]-[CONTINUOUS SERVICE DATE])/12

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Update, solved it myself as below

if [TERMINATION DATE] = #date(4721, 12, 31) then

Duration.Days(Date.From(DateTime.LocalNow()) - [CONTINUOUS SERVICE DATE]) /12

else

Duration.Days([TERMINATION DATE]-[CONTINUOUS SERVICE DATE])/12

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.