Syntax
[age,chkd,refd]=ageofbirthday(day,[refd])
Input Parameter
day : | | string of birthday, such as '30.11.1965) |
refd : | | string of refence date, such as {1.6.2016'; default is now |
Output Parameter
age : | | age in years |
chkd : | | numerical value of date |
refd : | | numerical value of reference date |
Examples
ageofbirthday('30.11.1965')
ageofbirthday('30.11.1965','1.10.1984')
ageofbirthday('30.11.1965','3.2.1989')
ageofbirthday('30.11.1965','3.2.1993')
ageofbirthday('30.11.1965','2.7.1997')
ageofbirthday('30.11.1965','10.04.2010') % 1st election of Dean
ageofbirthday('30.11.1965','21.10.2010') % Birthday of SG-Lib
Copyright 2022-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Algorithm (Workflow)
This function calculates the age in years based on a given birthday string and an optional reference date string. It is part of the SolidGeometry library.
Input Parameters
- day: A string representing the birthday, e.g., '30.11.1965'.
- refd: An optional string representing the reference date, e.g., '1.6.2016'. If not provided, the current date is used.
Output Results
- age: The age in years.
- chkd: The numerical value of the birthday date.
- refd: The numerical value of the reference date.
Algorithm Steps
- Set the reference date (
refd
) using the function getfuncparams
. If not provided, use the current date.
- If
refd
is a string and contains 'tim', set refd
to '30.11.1965'.
- Convert
refd
to a numerical date using datenum
and datetime
.
- Convert the birthday (
day
) to a numerical date using datenum
and datetime
.
- Calculate the age in years as
(refd - chkd) / 365.25
.
- If the age is positive, calculate the years and months. Use
floor
for years and round
for months.
- If the age is negative, use
ceil
for years and round
for months.
- If no output is requested, print the age in years and months using
dbprintf
.
- If output is requested, return the age.
Algorithm explaination created using ChatGPT on 2025-08-19 06:53. (Please note: No guarantee for the correctness of this explanation)
Last html export of this page out of FM database by TL: 2025-09-21