ACC2000: How to Display Only the Last Two Digits of Any Year (209663)



The information in this article applies to:

  • Microsoft Access 2000

This article was previously published under Q209663
Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

SUMMARY

This article describes how to display only the last two digits of the year.

The expression

=Year(Now())

displays all four digits of the current year (for example, 1999).

In order to display only the last two digits of the year (for example, 99), use one of the following expressions:

=Format(Now(),"yy")

-or-

=Right(Str(Year(Now())),2)

The breakdown of expression 2 is as follows:
  • Now() returns today's date and time.
  • Year(Now()) returns the current year.
  • Str(...) converts the date to a String data type.
  • Right(...,2) returns the right two characters.
NOTE: The right two characters are returned as a text value. If you want them to be returned as a number, use the following expression:

=Year(Now()) Mod 100

REFERENCES

For more information about the first expression, click Microsoft Access Help on the Help menu, type format property - date/time data type in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

For more information about the elements in the second expression, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type year function, right function, str function, or now function in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

Modification Type:MajorLast Reviewed:6/24/2004
Keywords:kbhowto kbusage KB209663