You are viewing limited content. For full access, please sign in.

Question

Question

Using Date calculation functions in Forms 10.2 with a Date of Birth before 1 Jan 1969 fails

asked on March 13, 2017 Show version history

Hi guys,

We need to calculate the age of a person based on the completion of two date fields.  In testing it works fine with the following formula until the Date of Birth ("DOB") is prior to 1 Jan 1969:

=DATEDIF(DOB,Date,"y")

(I've got an IF statement as well to avoid a blank field error, but that's the primary formula.)

I'm in NZ so am formatting the date fields as "dd-MMM-yy" in order for the calculations to work.  For the following examples, I'm using today's date in the "Date" field (14 Mar 2017).

If I set the DOB to 1 Jan 1969 then the calculation returns "48" so that's fine.  As soon as I make the date earlier than 1 Jan 1969 the calculation is wrong e.g. setting DOB to 31 Dec 1968 I get "-51".  

If I configure the date fields to a Year Range of "100 years prior to 0 years in the future" I also get the error (when entering a date before 1 Jan 1969) of: "Value must be between 1917-01-01 and 2017-12-31".

I'm going to look for a different function than DATEDIF for age calculations.

 

Update:  I've encountered the same issue using the FLOOR function:  =FLOOR((Date-DOB)/365.25,1))

Update 2:  The SUM function fails pre 1 Jan 1969 as well:  =SUM((Date-DOB)/365.25)

 

Cheers,

Mike

0 0

Answer

SELECTED ANSWER
replied on March 13, 2017

Your format string "dd-MMM-yy" suggests that you are using only 2 digits for the year, so the system has to guess which century you mean.  Can you supply the full year?

2 0
replied on March 13, 2017

Hi Brian,

Good point, that makes sense and is the answer of course.  I'm used to using date calculations in JS and only being able to use the "dd-MMM-yy" format.  I'll change the formatting, thanks for that.

Cheers,

Mike

0 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.