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
check date of birthday
-
- Administrator
- Posts: 79522
- 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
Hans
-
- PlatinumLounger
- Posts: 4512
- Joined: 26 Apr 2010, 17:36
Re: check date of birthday
HansV wrote: ↑11 Aug 2022, 09:18Code: Select all
Dim DateOfBirth As Date Dim IsMinor As Boolean DateOfBirth = ... IsMinor = (DateOfBirth > DateAdd("yyyy", -18, Date))
wath you think about?
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
-
- Administrator
- Posts: 79522
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: check date of birthday
That should work too. I don't know what DNASCITA is for, though.
Best wishes,
Hans
Hans