> For the complete documentation index, see [llms.txt](https://concentra-analytics.gitbook.io/working-with-data/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://concentra-analytics.gitbook.io/working-with-data/dates/age.md).

# Age

Most tools do not have a specific age function so you need to use a version of a `Date difference` calculation. For more information on these, go to [Dates > Date Difference](https://orgvue.gitbooks.io/formula-translator/content/dates/datedifference.html).

## Excel

Excel does not have a specific Age function so use `=DATEDIF()` and supply today's date as the end date. \
&#x20;\=\~DATEDIF!\~(‹start\_date›, \~TODAY()!\~, "‹date\_part›")

```
=DATEDIF(A1, TODAY(), "D")
```

NB. Supported date parts are as follows (all fractions are rounded down):

| Date Part | Equates to                                           | Min : Max Values |
| --------- | ---------------------------------------------------- | ---------------- |
| "D"       | Days                                                 | -∞ : ∞           |
| "M"       | Months                                               | -∞ : ∞           |
| "Y"       | Years                                                | -∞ : ∞           |
| "MD"      | Days (irrespective of month & year of the two dates) | 0 : 30           |
| "YD"      | Days (irrespective of the year of the two dates)     | 0 : 364          |
| "YM"      | Months (irrespective of the year of the two dates)   | 0 : 11           |

## Tableau

Tableau does not have a specific Age function so use `DATEDIFF()` and supply today's date as the end date. \
&#x20;\~DATEDIFF!\~('‹datepart›', ‹start\_date›, \~TODAY()!\~«, start\_of\_week»)

```
DATEDIFF('year', [Date of Birth], TODAY())
```

NB.

* «start\_if\_week» is used to determine rounding of weeks. If omitted, it is determined by Tableau automatically from the data source.
* Supported date parts are as follows  (all fractions are rounded up):

| Date Part | Equates to |
| --------- | ---------- |
| 'year'    | Years      |
| 'quarter' | Quarters   |
| 'month'   | Months     |
| 'week'    | Weeks      |
| 'day'     | Days       |
| 'hour'    | Hours      |
| 'minute'  | Minutes    |
| 'second'  | Seconds    |

## Alteryx

Alteryx does not have a specific Age function so use `DATETIMEDIFF()` and supply today's date as the end date. \
&#x20;\~DATETIMEDIFF!\~(‹start\_date›, \~DATETIMETODAY()!\~, ‹date\_part›)

```
DATETIMEDIFF([Date of Birth], DATETIMETODAY(), 'year')
```

NB. Supported date parts are as follows (all fractions are rounded down):

| Date Part            | Equates to |
| -------------------- | ---------- |
| 'year' / 'years'     | Years      |
| 'month' / 'months'   | Months     |
| 'day' / 'days'       | Days       |
| 'hour' / 'hours'     | Hours      |
| 'minute' / 'minutes' | Minutes    |
| 'second' / 'seconds' | Seconds    |

## OrgVue

node.‹date›.\~age!\~('«date\_part»')

```
node.dateofbirth.age('y')
```

NB. Supported date parts are as follows (fractions are not rounded):

| Date Part | Equates to |
| --------- | ---------- |
| 'y'       | Years      |
| 'q'       | Quarters   |
| 'm'       | Months     |
| 'w'       | Weeks      |
| 'd'       | Days       |

## tSQL

tSQL does not have a specific Age function so use `DATEDIFF()` and supply today's date as the end date. \
&#x20;\~DATEDIFF!\~(‹date\_part›, ‹start\_date›, \~GETDATE()!\~)

```
SELECT DATEDIFF(year, DateOfBirth, GETDATE()) AS Age
FROM EmployeesData
```

NB. Supported date parts are as follows (fractions are not rounded):

| Date Part   | Equates to    |
| ----------- | ------------- |
| year        | Years         |
| quarter     | Quarters      |
| month       | Months        |
| day         | Days          |
| week        | Weeks         |
| hour        | Hours         |
| minute      | Minutes       |
| second      | Seconds       |
| microsecond | Mircroseconds |
| nanosecond  | Nanoseconds   |

## Python

Python does not have a specific Age function so use: \~datetime.date!\~(‹end\_date›) - \~datetime.date.!\~(‹start\_date›)

```
from datetime import date 
# so you don't have to reference datetime.date() to call each date

date(finishDate) - date.(transferDate)
# OR
date(2016,10,18) - date(2015,11,23)
```

This returns a date object. To unpack it as a number of days, wrap the difference expression in `()` and append `.days`:

```
from datetime import date

(date(2016,10,18) - date(2015,11,23)).days
```

NB.

* This requires the `datetime` library to be imported. &#x20;
* This returns the difference in days which can be divided/multiplied to give other units.
* When manually creating a date, days and months must be entered as a single digit when < 9 (with no padding '0'), e.g. `date(2016,9,20)`.&#x20;
* The example above assumes variables have been declared for `finishDate` and `transferDate`. For more information, go to [General > Variables](https://orgvue.gitbooks.io/formula-translator/content/general/variables.html).
