A common use of Fdate is to format today's date and use it to rename a file
(typically a log file of some sort). You may wish to store the date
information in as few characters as possible, in order to maximize the
number of other characters in the filename that you can use to store other
In this example, and the next one, I illustrate two ways to store a date in
The simplest way is to represent today's date as a 4-digit number.
To do this, we first pick a base date: I'll use January 1, 1990.
Then it is a simple matter to calculate the number of days between today
and the base date:
FDATE /Fdif /at /b01-01-1990
Starting in 1993, this will always generate a 4-digit number, and will
continue to do so for 20 years, until approximately the year 2003. Dates
before 1993 may produce 1-, 2-, or 3-digit numbers, and dates after 2003
will begin to produce 5-digit numbers. But this technique will work quite
nicely for most ordinary purposes for the next 20 years.
In the year 2003 you can switch to using January 1, 2000 as your base
date and function quite nicely for the next 20 years after that.