Date Default Value

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?
 
A

Allen Browne

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
 
R

Rick Brandt

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.
 
T

Tim Ferguson

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
 

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