% This is an example document accompanying "LaTeX for Administrative Work"
% See www.dickimaw-books.com/latex/admin/ for the book details,
% including licence.

% Arara directives to build the document:
%
% arara: pdflatex
% arara: pdflatex
\documentclass[captions=tableheading]{scrartcl}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{pgfkeys,pgfcalendar}
\usepackage{datatool}

\DTLloaddb{people}{people.csv}

\newcount\julianday
\newcount\juliantoday
\newcount\age

% Compute the Julian day number for today:
\pgfcalendardatetojulian{\year-\month-\day}{\juliantoday}%

\begin{document}
Ages as of \number\year-\number\month-\number\day\ are
listed in Table~\ref{tab:ages}.

\begin{table}[htbp]
\caption{Ages (as of \number\year-\number\month-\number\day)}
\label{tab:ages}
\centering
\begin{tabular}{lc}
\bfseries Name & \bfseries Age%
\DTLforeach*{people}%
 {\Forenames=forenames,\Surname=surname,\DoB=dob}%
 {%
    \\\Forenames\ \Surname &
    % Compute the Julian day number for the date of birth
    \pgfcalendardatetojulian{\DoB}{\julianday}%
    % Compute \age = (\juliantoday - \julianday)/365
    \age=\juliantoday
    \advance\age by -\julianday
    \divide\age by 365\relax
    \number\age
 }%
\end{tabular}
\end{table}

Non-ISO format:
\def\DoB{12/2/1995}%
\def\parsemdydate#1/#2/#3\endparsemdydate{#3-#1-#2}%
\pgfcalendardatetojulian{\expandafter\parsemdydate\DoB\endparsemdydate}{\julianday}%
% Compute \age = (\juliantoday - \julianday)/365
\age=\juliantoday
\advance\age by -\julianday
\divide\age by 365\relax
DoB = \DoB, age = \number\age.

\end{document}
