Date Default Value

  • Thread starter Thread starter Sondra
  • Start date Start date
S

Sondra

I have a date default value set as Year(Date()). I want
it to only show the last two digits of the year in the
field. Can this be accomplished?
 
Internally, Access stores dates as the number of days since Dec 30 1899. If
you try to force the value 2003 into a date field, it may not accept it, or
it might interpret the value as Jun 25 1905.

If you have a date field that contains a real date, and you want to display
it as the last 2 digits of the year only, you could set the text box's
Format property to:
yy
 
Sondra said:
I have a date default value set as Year(Date()). I want
it to only show the last two digits of the year in the
field. Can this be accomplished?

Year() returns an integer. When you place that value into a Date field you will
not get what you are expecting.

Just use Date() as the default and then format it to only show the last two
digits of the year with a format property of "yy". A Date field in Access
always includes a full date and a full time. If you only want to store portions
then you need to use a numeric field instead.
 
I did this and it only shows 3 for the year 2003. I need
it to show 03.

If you want a string value, then you have to use an explicit cast:

=Format(Year(Date()) mod 100, "00")

Tim F
 
Back
Top