Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- RLIB 3.0a Reference - <b>function:</b> revdate() http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Function:    REVDATE()

Purpose:     Reverse date fields to index in reverse chronological order.

Syntax:      REVDATE( date )

Arguments:   date        - Date type field or variable to be reversed.

Returns:     A character string which, when used as an index key, will
             order a database in reverse chronological order with the most
             recent dates first.

Description: REVDATE() is a date function which REVerses a DATE to allow
             indexing and/or searching on dates in descending order.  The
             function converts the year, month, and day into a reverse
             string format to formulate a descending date order.  As an
             example:

             date                     = CTOD("01/31/87")
             STR(3000-YEAR(date),4,0) = STR(3000 - 1987) = "1013" +;
             STR(13-MONTH(date),2,0)  = STR(13 - 1 )     = "12"   +;
             STR(32-DAY(date),2,0)    = STR(32 - 1 )     = "31"
             REVDATE(date)            = "10131231"

             Example dates: (note that dates must be converted from char)

             REVDATE(CTOD("01/01/88")) = "10111231"
             REVDATE(CTOD("02/01/88")) = "10111131" *-- note that this
             places the date 02/01/88 before 01/01/88

Notes:       Since REVDATE() has parameter error checking built in, there
             is some overhead associated with each function call.  If you
             plan on using REVDATE() in an indexing key you may want to
             remove the RlibInit() and TYPE() error checking lines to
             decrease overhead and increase indexing speed.  However, if
             REVDATE() is to be used dynamically, as in ad hoc user
             querying or reporting, you as the application programmer must
             ensure that the proper date type is passed as a parameter
             since REVDATE() will no longer check.

Example:     *-- order customer sales database with most recent sale first
             IF .NOT.  OPENED("Sales")
                RETURN
             ENDIF
             INDEX ON Customer + REVDATE(SaleDate) TO sales.ntx

Source:      RL_REVDA.PRG

See also:    ALPHADATE(), STR2DATE()

See Also: ALPHADATE() STR2DATE()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson