Forum

Notifications
Clear all

Calculating Age

4 Posts
2 Users
0 Reactions
87 Views
(@paulma)
Posts: 17
Eminent Member
Topic starter
 

Hi, I'm adding a Custom Column called Age to a query, using this formula:

 = DateTime.LocalNow() - [Install Date]

[Install Date] is a column of dates, formatted as Date.

I want to calculate the age of equipment. I've tried formatting the custom column as Date and Whole Number, but I only get an error with both.

What am I doing wrong? TIA, Paul

 
Posted : 01/02/2022 12:08 pm
(@paulma)
Posts: 17
Eminent Member
Topic starter
 

For the benefit of anyone looking for a solution, the following formula gives me the days' duration, formatted as Whole Numbers:

 = Date.From(DateTime.LocalNow()) - [Install Date]

I'm looking for a way to format, either as months, or years and months. If I can't do it in PQ, it's easy enough in Excel...

 
Posted : 01/02/2022 12:22 pm
(@paulma)
Posts: 17
Eminent Member
Topic starter
 

And now I see that there's a built-in Calculation for this on the Add Column tab... 🙂 

 
Posted : 01/02/2022 12:36 pm
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

🙂

 
Posted : 02/02/2022 12:33 am
Share: