Date Mask auto changes 1916 to 2016

D

Dow_Jones

The current date mask I have for my membership birthdays, date joinedm etc.
is" '99/99/00;0'. The results have been fine until I entered a birthdate of
11/20/16 which should have returned 11/20/1916 as an entry of 8/31/31 does.
What changes to mask need to be made to have these older dates appear
correctly? Is '99/99/0000;0' the only choice I have?

Thanks for your help.
 
D

Dirk Goldgar

Dow_Jones said:
The current date mask I have for my membership birthdays, date joinedm
etc.
is" '99/99/00;0'. The results have been fine until I entered a birthdate
of
11/20/16 which should have returned 11/20/1916 as an entry of 8/31/31
does.
What changes to mask need to be made to have these older dates appear
correctly? Is '99/99/0000;0' the only choice I have?


If you enter dates with a two-digit year, Access has to use some rule to
decide what century that year is in. I believe it uses the current date
window, as specified in your Windows regional settings. This defaults to
1930 to 2029.

If you're only using this database on your own computer, and you want all
two-digit years entered on your computer (in any application) to be
interpreted the same way, you can change that regional setting. Otherwise,
your best option (IMO) is to allow a 4-digit year to be entered.
Personally, I don't use date masks much, because I like the freedom of
entering the date in a number of ways and letting Access interpret it.

If you want to use a date mask that requires a 2-digit year, but override
the normal date-windowing in just this case, you can use code in your text
box's AfterUpdate event to change the value to what you think is reasonable
for this application. You might want to take into account exactly what type
of date is being entered. Maybe it would look like this:

'----- start of code -----
Private Sub txtBirthDate_AfterUpdate()

With Me.txtBirthDate
If Not IsNull(.Value) Then
If Year(.Value) >= Year(Date() Then
' Must be the previous century!
.Value = DateAdd("yyyy", -100, .Value)
End If
End If

End Sub
'------ end of code ------

It would be up to you to decide where your own century cut-off. The above
example just assumes that the individual wasn't born this year or later.
 
J

John W. Vinson

The current date mask I have for my membership birthdays, date joinedm etc.
is" '99/99/00;0'. The results have been fine until I entered a birthdate of
11/20/16 which should have returned 11/20/1916 as an entry of 8/31/31 does.
What changes to mask need to be made to have these older dates appear
correctly? Is '99/99/0000;0' the only choice I have?

Thanks for your help.

Would you want a birthdate typed as 3/12/09 to enter 2009? or 1909? It might
be either. Or you might have both - a centenarian member and her
great-great-grandson!

Access must have some way to resolve ambiguous two-digit years. The convention
(which can be overridden) is that two digit years 00-29 are in the 21st
century, and 30-99 in the 20th.

If you're recording people's birthdates... use four digit years. You really
have no choice with lifespans as they are these days!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top