Date of birth checker

Creating and using forms
Post Reply
Rakau
Posts: 1
Joined: Tue Jul 05, 2016 11:15 am

Date of birth checker

Post by Rakau »

I am trying to create a constraint on a date of birth field.
If a student was registering for a driver licence, and they must be (say) 16 years old, but entered a DOB that was short of the required 16 years,how can this be flagged to show not valid?
Thanks
LibreOffice 5.1.3.2 on Windows 8
User avatar
Sliderule
Volunteer
Posts: 1279
Joined: Thu Nov 29, 2007 9:46 am

Re: Date of birth checker

Post by Sliderule »

[quote=""Rakau"]I am trying to create a constraint on a date of birth field.
If a student was registering for a driver licence, and they must be (say) 16 years old, but entered a DOB that was short of the required 16 years,how can this be flagged to show not valid?[/quote]
Yes. The answer in the post below ( look at the posts by both Sliderule and Villeroy ) , assumes with your use of LibreOffice Base as your database back-end, and, HSQL Embedded Database as your database back-end, that is HSQL 1.8.0.10 ( you can confirm this be looking that the Status Bar at the bottom after starting your Base File ( *.odb ) ).

viewtopic.php?f=13&t=36069&p=165388

Explanation:
  1. By performing the calculation as noted in the link above, you can determine the AGE in years. This calculation can be also be used, for example:
    1. Code: Select all

      CASEWHEN(calculation >= 16,'Valid','Not Valid') as "Age_At_Least_16"
    2. Code: Select all

      CASE WHEN calculation >= 16 THEN 'Valid' Else 'Not Valid' End as "Age_At_Least_16"
  2. If you are using HSQL 2.X, or, another database back-end, let us know, since that SQL calculation might be different. :crazy:
I hope this helps, please be sure to let me / us know. :super:

Sliderule
Post Reply