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)]]


The '''Date''' function calculates and returns dates in numeric format, using no dashes or slashes as separators. The "C" - century format specification is now fully supported. If the century is not specified, it is simply not printed.
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.


====Examples====
====Examples====
PRINT DATE$("M/D/CY")
output: 07/10/1992


  PRINT DATE$(Days(07101992,"MDCY"),"M/D/Y")
Executing the following statement on July 10, 1992
output: 07/10/92
 
  PRINT DATE("MDCY")
 
results in the following output:  
 
7101992


  PRINT DATE$(Days(07102092,"MDCY"),"M/D/Y")
'''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.
output: 07/10/92
 
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.
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====
====Comments and Examples====
  00010 PRINT FIELDS "10,10,cr 20": "Enter Posting Date:"
 
  00020 PRINT FIELDS "10,43,n 6,r": DATE("mmddyy")
  00010 PRINT FIELDS "10,10,CR 20": "Enter Posting Date:"
  00030 INPUT FIELDS "10,43,n 6,r3": POSTDATE
  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.
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.


====Parameters====
====Technical Considerations====
The DATE function cannot be used in READY mode unless it includes parameters. If you type in "DATE" and press <CR>, you will be using the DATE command (which uses a different default format than the DATE function does).
 
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).
 
The optional "format$" parameter is a string expression which identifies the format of the value to be returned. When the first character of the string expression is an asterisk (*), it identifies the default format which should be used by the DATE, DATE$ and Days parameters until the workstation exits Business Rules until the format is changed again. (Format changes affect the current workstation only.)


The format$ parameter may include editing characters (which are ignored by DATE) and any of the following date specifications: D (day), M (month), Y (year) or C (century). The total number of editing characters and date specifications may not exceed 6. Consecutive repetitions (DDD, YY, etc.) of the date specifications count as just one specification. See the DATE$ function for additional information about format$.
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====
====Related Functions====

Revision as of 08:58, 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.

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.