Date formatting

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using the date format 05/19/2005 in a table and when I type 5/25/35 it
changes to 5/25/1935. is there a way to default it to 5/25/2035?
 
This is the basic problem of the Y2K bug. Your best solution is to enter the
4-digit year.

I have used an after update macro to test and fix.

if me.date < #12/31/1940# then me.date = format(me.date,"mm/dd/") &
Year(me.date) + 100

I did not test it. The problem with this logic is when do you make the
switch.
 
I am using the date format 05/19/2005 in a table and when I type 5/25/35 it
changes to 5/25/1935. is there a way to default it to 5/25/2035?

Two-digit years are inherently ambiguous (remember the flap about the
Y2K bug?)

Access' solution is to use January 1, 1930 as the dividing line: two
digit dates from 30 through 99 are assumed to be in the 20th century,
those from 00 through 29 in the 21st.

If you'll never be entering 20th century dates, you can use an
AfterUpdate event on the Form (not a Table, which has no usable
events) to correct it:

Private Sub txtDatefield_AfterUpdate()
If Me!txtDatefield < #1/1/2000# Then
Me!txtDatefield = DateAdd("yyyy", 100, Me!txtDatefield)
End If
End Sub

John W. Vinson[MVP]
 
Back
Top