How to subtract two dates to calculate date difference, like the age of a person?

 

Question:

How to subtract two dates to calculate date difference, like the age of a person?

 

Answer:

With Caspio "Calculated Field" feature, you can find the difference of two dates and calculate for example the age of a person to year, month or day granularity.

The article about calculated fields describes the function Datediff(year, [@field:DOB], GetUTCDate() to calculate age. To use this function to calculate at month and day granularity try:

Datediff(month,[@field:DateLogged],GetUTCDate())/12

Datediff(day,[@field:DateLogged],GetUTCDate())/365

More information about all the parameters and options of DateDiff is available at http://msdn.microsoft.com/en-us/library/ms189794.aspx.