Microsoft KB Archive/95951

{|
 * width="100%"|

XL: Displaying the Current Date and Time with Text

 * }

-

The information in this article applies to:


 * Microsoft Excel for Windows, versions 2.x, 3.0, 4.0, 4.0a, 5.x
 * Microsoft Excel for Windows 95, versions 7.0, 7.0a
 * Microsoft Excel 97 for Windows
 * Microsoft Excel for the Macintosh, versions 2.x, 3.0, 4.0, 5.x
 * Microsoft Excel 98 Macintosh Edition
 * Microsoft Excel for OS/2, versions 2.2, 3.0

-

SUMMARY
You can enter the current date and/or time as text by using the TEXT function with the TODAY or NOW functions. For example, to display &quot;Today is 2/18/98&quot; (without the quotations marks), where 2/18/98 is the current date, use the following formula:

  =&quot;Today is &quot;&TEXT(TODAY,&quot;m/d/yy&quot;)

NOTE: You can substitute the NOW function for the TODAY function in the above formula to display the date and time or just the time (depending on the number format you specify).

You can also display &quot;Today is 2/18/98&quot; (without the quotation marks), and preserve the value of the date as a serial number rather than converting it to text.

To display the current time, use the following formula:

   =NOW-TODAY

This formula will update each time the sheet is calculated.

MORE INFORMATION
The TEXT function converts a value to text in a specified number format.

To display the following

  The current date and time is 2/18/93 5:57 PM

use this formula:

  =&quot;The current date and time is &quot;&amp;TEXT(NOW,&quot;m/d/yy h:mm AM/PM&quot;)

To display the following

  The current time is 5:57 PM

use this formula:

  =&quot;The current time is &quot;&TEXT(NOW,&quot;h:mm AM/PM&quot;)

If you want a linked formula in a chart to display this information but you do not want to open the file, use the TEXT function (as discussed above).

To display the time but preserve the value as a serial number, follow these steps:


 * 1) Select the cell you want to format.
 * 2) On the Format menu, click Number. (Or, click Cells on the Format menu, and then click the Number tab.) In the Category list, click Date or Custom.
 * 3) In the Code or Type entry box, type &quot;Today is &quot; (including the quotation marks and one space after &quot;is&quot;) immediately followed by the date format you want to use (for example, m/d/yy, or d/mmm/yy), and then click OK.
 * 4) In the formatted cell, type =TODAY.

The cell will display &quot;Today is m/d/yy&quot; (where m/d/yy is the current date and is displayed in the format you selected in step 3). The value of the date is stored as a serial number.