Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

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

↑ Back to the top


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.

↑ Back to the top


Keywords: KB209663, kbusage, kbhowto

↑ Back to the top

Article Info
Article ID : 209663
Revision : 2
Created on : 6/24/2004
Published on : 6/24/2004
Exists online : False
Views : 270