Forum Discussion
Today - Column Date = Age
Hi
I have a table with a date issued column , however some of the fields are blank . I would like to use a custom column function to do the following.
If date column - blank return blank else todays date - date issued / 365.24 = date in years (1 decimal point)
Example of table and expected result
| Issue Date | Age in years |
| 01/02/2022 | 0.3 |
| 02/02/2021 | 1.3 |
| 03/02/2020 | 2.3 |
| 09/02/2022 | 0.3 |
| 10/02/2022 | 0.3 |
| 11/02/2019 | 3.3 |
| 12/02/2021 | 1.3 |
| 13/02/2022 | 0.3 |
| 15/02/2010 | 12.3 |
| 15/02/2022 | 0.3 |
| 13/02/2018 | 4.3 |
| 14/02/2017 | 5.3 |
| 15/02/2013 | 9.3 |
| 16/02/2012 | 10.3 |
thank you
Richard
If you have already converted your column to date column, then blanks will be converted to null.
In this case, use below formula
= Number.Round(Duration.Days(Date.From(DateTime.FixedLocalNow())-[Issue Date])/365.24,1)But looks like, you haven't converted the column to date, then you will have to use below formula
= Number.Round(Duration.Days(Date.From(DateTime.FixedLocalNow())-(if [Issue Date]="" then null else Date.From([Issue Date])))/365.24,1)
2 Replies
- Vijay_A_VermaMost Valuable Professional
If you have already converted your column to date column, then blanks will be converted to null.
In this case, use below formula
= Number.Round(Duration.Days(Date.From(DateTime.FixedLocalNow())-[Issue Date])/365.24,1)But looks like, you haven't converted the column to date, then you will have to use below formula
= Number.Round(Duration.Days(Date.From(DateTime.FixedLocalNow())-(if [Issue Date]="" then null else Date.From([Issue Date])))/365.24,1) - cottreraPost Prodigy
Perfect work fine thank you 😀