Age
Last updated
Was this helpful?
Last updated
Was this helpful?
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 .
Excel does not have a specific Age function so use =DATEDIF()
and supply today's date as the end date.
=~DATEDIF!~(‹start_date›, ~TODAY()!~, "‹date_part›")
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 does not have a specific Age function so use DATEDIFF()
and supply today's date as the end date.
~DATEDIFF!~('‹datepart›', ‹start_date›, ~TODAY()!~«, start_of_week»)
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 does not have a specific Age function so use DATETIMEDIFF()
and supply today's date as the end date.
~DATETIMEDIFF!~(‹start_date›, ~DATETIMETODAY()!~, ‹date_part›)
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
node.‹date›.~age!~('«date_part»')
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 does not have a specific Age function so use DATEDIFF()
and supply today's date as the end date.
~DATEDIFF!~(‹date_part›, ‹start_date›, ~GETDATE()!~)
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 does not have a specific Age function so use: ~datetime.date!~(‹end_date›) - ~datetime.date.!~(‹start_date›)
This returns a date object. To unpack it as a number of days, wrap the difference expression in ()
and append .days
:
NB.
This requires the datetime
library to be imported.
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)
.
The example above assumes variables have been declared for finishDate
and transferDate
. For more information, go to .