Date formats using DateAdd - year shows as 4 digits (sometimes)

G

Guest

I have a text box on a small form whose control is a date field in a table.
The format is set to short date, and the input mask is 00/00/00;0;_ as is
the field in the table.

The date is updated by a macro which runs on AfterUpdate event of an options
group (of 5 options) elsewhere on the same form. Dependent on the option
selected, the macro performs a 'DateAdd'. The condition in the macro will
add 1 year to the date, except when just the 4th option is selected, when it
adds 25 years, using this: DateAdd("yyyy",25,Date()). It all works fine
until I set the 4th option.

It's here that it goes a little odd. The date will show 15/11/2030 despite
all my efforts. Then I tried adding 20 years in the DateAdd, and it shows
correctly as 15/11/25 with a 2 digit year! It works correctly as far as
adding 24 years which shows 15/11/29, but as soon as I go past 25, it shows 4
digits 2030 for the year. It does the same if I change the DateAdd to use
Now(). The date gets stored in the underlying table in the same way. My
control panel settings are set to short date UK format. All other date
fields on this and numerous other forms in my database display correctly.
Any ideas? Is this something which occurs to remind me that it's this
century and not last?
 
D

Douglas J Steele

I'm wondering whether it's related to the "When a two-digit year is entered,
interpret it as a year between" setting (in the Control Panel on the Date
tab in Regional and Language Options when you've chosen Customize from the
Regional Options tab)

See whether changing that to, say 2050, solves your problem.
 
G

Guest

Douglas, you are a star! That's exactly what it was. I tried all sorts and
thought I'd looked everywhere (clearly not enough). I vaguely remembered
seeing a reference to it. I couldn't find it on the MS Knowledge Base nor on
here, and I usually get answers to all my Access questions here, so thanks to
all those who contribute. Now I know the answer, I've found it in Windows
help. Sheesh!

Thanks again.
 

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

Similar Threads


Top