Date (internal function): Difference between revisions

From BR Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
See also [[Date (disambiguation)]]
See also [[Date (disambiguation)]]


  DATE([DAYS], [order_of_components$])
  DATE([DAYS], [[*]order_of_components$])


The '''Date''' function calculates and returns dates in ''numeric format'', using no dashes or slashes as separators.  
The '''Date''' function calculates and returns dates in ''numeric format'', using no dashes or slashes as separators.  
Line 8: Line 8:


When '''order_of_components$''' is specified, the date is printed accordingly. order_of_components$ may be any combination of the four letter M (month, D (day), C (century), Y (year). Including each of these components results in a two-digit corresponding month, day, century, or year. When any of these 4 components is omitted, it is not returned by the function or printed.
When '''order_of_components$''' is specified, the date is printed accordingly. order_of_components$ may be any combination of the four letter M (month, D (day), C (century), Y (year). Including each of these components results in a two-digit corresponding month, day, century, or year. When any of these 4 components is omitted, it is not returned by the function or printed.
If the order_of_components$parameter begins with an asterisk (*), then the default format is changed. The default format affects results of the Date, Date$ and Days functions. This change applies only to the current computer and stays in effect until you leave BR.


====Examples====
====Examples====

Revision as of 09:03, 24 January 2012

See also Date (disambiguation)

DATE([DAYS], [[*]order_of_components$])

The Date function calculates and returns dates in numeric format, using no dashes or slashes as separators.

The optional "days" parameter represents the desired date as a sequential value in relation to a base date of January 1, 1900. Thus January 1, 1900 would have a days value of 1; January 1, 1901 would have a days value of 366 (1900 was not a leap year).

When order_of_components$ is specified, the date is printed accordingly. order_of_components$ may be any combination of the four letter M (month, D (day), C (century), Y (year). Including each of these components results in a two-digit corresponding month, day, century, or year. When any of these 4 components is omitted, it is not returned by the function or printed.

If the order_of_components$parameter begins with an asterisk (*), then the default format is changed. The default format affects results of the Date, Date$ and Days functions. This change applies only to the current computer and stays in effect until you leave BR.

Examples

Executing the following statement on July 10, 1992

PRINT DATE("MDCY")

results in the following output:

7101992

Note that BR does not print the zero in front of the month July (07), as this is not necessary for numeric calculations. If you do not need the numeric value of the date, use the Date$ function instead.

Consider another example, in which 33794 is the number of days which passed between January 1, 1900 and July 10, 1992:

PRINT DATE(33794,"MDY")

with the following output:

7101992

The DATE function should not be confused with the DATE command, which may be used to reset or display the current system date.

Comments and Examples

00010 PRINT FIELDS "10,10,CR 20": "Enter Posting Date:"
00020 PRINT FIELDS "10,43,N 6,r": DATE("mdy")
00030 INPUT FIELDS "10,43,N 6,r3": POSTDATE

Line 20 displays the current system date as a number in the format month, day and year. Line 30 positions the cursor to the third digit and allows the operator the option to change the displayed date by typing over all or part of it.

Technical Considerations

The DATE function cannot be used in READY mode unless it includes parameters. If you type in "DATE" and press <ENTER>, you will be using the DATE command, which uses a different default format than the DATE function does.

Related Functions

See also Date$ and Days for other date processing functions. To set the system date, use the Date command. For features especially useful in markets outside the United States, see the INVP parameter of the Option statement and the PIC$ function in the Format Specifications.