The information in this article applies to:
SUMMARYThis article provides several examples of how to use WordBasic macros to perform calculations on dates and times. Word does this by first converting a date or time into a "serial number." Word then uses the serial number in calculations and converts it back into a standard date or time format. EXAMPLESTo insert a date seven days from the current date:
To insert "July 1, 1925" or "07/01/25" (without the quotation marks)
(because this date is one-half of December 31, 1950, in number of days when
December 30, 1899 is 0 [zero]):
To calculate how many days old you are, where mm/dd/yy is your birthdate,
and display that number in a message box:
To insert 6:00 AM (because 6:00 AM is one-half of 12:00 PM):
To insert the current date and time:
To calculate the last day of the previous month:
MORE INFORMATIONThe date serial number is a whole number that represents the number of days between December 30, 1899, and the specified date, up to December 31, 4095. Here are some examples:
The time serial number is a decimal number between 0 and 0.99998842592593
that represents a time from 12:00:00 AM to 11:59:59 PM. For example:
Date functions include Date$(), DateSerial(), DateValue(), Day(),
Days360(), Today(), Month(), Weekday(), and Year().
Time functions include Time$(), TimeSerial(), TimeValue(), Hour(), Minute(), Second(), and Now(). NOTE: The date format is determined by the "DateFormat=" line in the [Microsoft Word] section of the WINWORD6.INI file (Windows), in the Word Settings (6) file (Macintosh), or in the Registry (Windows NT). (In Windows, if there is no "DateFormat=" line, Date$() uses the "sShortDate" setting in the [intl] section of the WIN.INI file.) You can use the SetPrivateProfileString macro to change the current date format. For more information on these functions and for examples of specific WordBasic commands, refer to the "Microsoft Word Developer's Kit," or choose Contents from the Help menu, then choose "Programming with Microsoft Word". Choose the "Statements and Functions Index" topic and select the desired command. REFERENCES"Microsoft Word Developer's Kit," version 6.0, pages 319-322, 511-512, 595- 596, 610, 659, 733-735, 812 and 820 Additional query words: seriel macro basic
Keywords : kbdta wordnt kbmacroexample winword ntword macword word6 word7 word95 |
Last Reviewed: October 4, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |