NumToDate

From CometWiki

(Difference between revisions)
Jump to: navigation, search
Jim (Talk | contribs)
(Initial Construction of page)

Latest revision as of 18:17, 7 December 2010

NUMTODATE function

Syntax: NUMTODATE(numeric-argument)

Discussion: The NUMTODATE function converts a date serial number to the corresponding date string.

The numeric-argument is a 6-digit value (variable or constant) that represents the number of days elapsed from a given base date. The base date is January 1, 1800. The greatest date covered by this function is December 31, 2299. The following chart demonstrates these values.

 Date serial number   Date string    Notes
 ==================================================
        0             "01011800"     Base date
   182620             "12312299"     Maximum value

This function returns an 8-byte date string in the following form: "MMDDYYYY" If the value of the numeric-argument is less than 0 or greater than 182620, the DATETONUM function will return an 8-byte string containing the following values: "000000"

The NUMTODATE function respects the rules for leap years (i.e., the years 1800 and 1900 were not leap years, but the year 2000 is a leap year).

The DATETONUM function converts a date string to a date serial number.

Also see DATE2NUM and NUM2DATE.

Example:

 LENGTH   8 & LOCAL VALUE$
 LENGTH 6.0 & LOCAL SERIAL
 . 
 .
 .
 PRINT (0) "ENTER A DATE SERIAL NUMBER (######):"
 INPUT (0) SERIAL
 IF SERIAL = 0 THEN RUN "QMONITOR"
 VALUE$ = NUMTODATE(SERIAL)
 PRINT (0) "THE DATE STRING IS:";VALUE$
Personal tools