## check date of birthday

sal21
PlatinumLounger
Posts: 4457
Joined: 26 Apr 2010, 17:36

### check date of birthday

How do I know if the Born = 12/01/2016 customer is a minor, i.e. under 18, based on the current date?

in this case is thrue

HansV
Posts: 79161
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

### Re: check date of birthday

Code: Select all

``````    Dim DateOfBirth As Date
Dim IsMinor As Boolean
DateOfBirth = ...
IsMinor = (DateOfBirth > DateAdd("yyyy", -18, Date))``````
Best wishes,
Hans

sal21
PlatinumLounger
Posts: 4457
Joined: 26 Apr 2010, 17:36

### Re: check date of birthday

HansV wrote:
11 Aug 2022, 09:18

Code: Select all

``````    Dim DateOfBirth As Date
Dim IsMinor As Boolean
DateOfBirth = ...
IsMinor = (DateOfBirth > DateAdd("yyyy", -18, Date))``````

In my code repository:

nato=11/12/2015

If AGE(nato) < 18 Then
stop
End If

Public Function AGE(BirthDate) As Long

M = DateDiff("M", BirthDate, Date)
D = DateDiff("D", DateAdd("M", M, BirthDate), Date)
If D < 0 Then
M = M - 1
End If
AGE = M \ 12

DNASCITA = BirthDate

End Function

note:
is a very old code, 2015

HansV