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

Last reviewed: April 2, 1997
Article ID: Q95907
The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1, 2.0, 7.0, 97

SUMMARY

Moderate: Requires basic macro, coding, and interoperability skills.

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, 1993).

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

   =Format(Now(),"yy")

   -or-

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

The breakdown of expression 2 is:
  • Now() returns the 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, search the Help Index for "formatting dates," or ask the Microsoft Access 97 Office Assistant.

For more information about the elements in the second expression, search the Help Index for "year," "right," "str," or "now."


Keywords : ExrOthr kbusage
Version : 1.0 1.1 2.0 7.0 97
Platform : WINDOWS
Hardware : X86
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 2, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.