PPWIZARD is a free preprocessor for HTML, REXX, Visual Basic or any text files.
[Bottom][Contents][Search][Prev]: Bd2Date()[Next]: Beeps()
\ -> Rexx -> Inbuilt PPWIZARD Functions -> BaseDate()

BaseDate()

This is an inbuilt function function provided by PPWIZARD.

This function can be called to work out a basedate (julian day) given a date. The integer will be negative if an error occurred. You can tell how many days apart 2 dates are by subtraction of one from the other. The basedate is the number of days since 1 January 0001.

If the returned basedate integer is divided by 7, the remainder will tell you what day of the week it is (where 0=Monday, 6=Sunday).

The number returned for a date is compatible with rexx's "date('BaseDate')" call.

You can convert a basedate back into a displayable date with BD2DATE().

You can use GetFileTimeStamp() to obtain the date/time a file was modified and calculate a basedate from this if you wish to calculate the age of a file.

INPUT DATE

The routine takes a single parameter (the date) with the year, month and day of month being supplied in that order. The year should either be supplied as 4 digits or will pivot at 1980.

It will take the input in these formats:

  1. YYYYMMDD - any following characters ignored.
  2. YY/MM/DD or YYYY/MM/DD
  3. YY-MM-DD or YYYY-MM-DD
  4. YY MM DD or YYYY MM DD
  5. If nothing passed (or blank) then todays date is used.

Note that for most formats it actually does not matter how many digits are supplied for day of month and month, however a resonable amount of validation occurs.

EXAMPLE INPUT DATES

  1. date('Sorted');
  2. date('Ordered');
  3. "98-2-12"
  4. "1998/02/01"
  5. "20001230"
  6. "20001230235959"

EXAMPLE CODE

The following code could be used in a web page which has an expiry (use by) date for some reason (maybe it counts down the days to an event):

#if basedate() > basedate('20011225')
    #error ^This page expired 25 Dec 2001^
#endif

This code works out the date a week from now and generates it in 2 formats:

#DefineRexx ''
       ;--- Get date in default format for 7 days from now ---
       BaseDateToday   = basedate();
       BaseDateIn7Days = BaseDateToday + 7;
       DateYYYYMMDD    = Bd2Date(BaseDateIn7Days);

       ;--- Convert to nicer format ---------
       parse var DateYYYYMMDD YYYY 5 MM 7 DD
       MmText = word('Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec', MM);
       DatePretty = DD+0 || ' ' || MmText || ' ' || YYYY;
#DefineRexx
Date in 7 Days
~~~~~~~~~~~~~~
DEFAULT: <??DateYYYYMMDD>    ;;Maybe "20010403"
PRETTY : <??DatePretty>      ;;Maybe "3 Apr 2001"


email me  any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Search][Prev]: Bd2Date()[Next]: Beeps()


PPWIZARD Manual
My whole website and this manual itself was developed using PPWIZARD (free preprocessor written by Dennis Bareis)
Sunday November 05 2017 at 10:00am