DATE() Function - Convert Julian to Calendar Date - BBj
Syntax
DATE (num1{,num2} {:str}{,ERR=lineref})
Description
For BBj- specific information, see the DATE() Function - BBj.
The DATE() function takes a Julian date and the optional time-of-day and formats it into a more familiar calendar date and time string.
Parameter | Description |
---|---|
num1 | Julian date. |
num2 | Time of day in SETTIME format (hours and fractional hours). If this parameter is not included, the current time is used. |
str | Output format of the result. If this parameter is not included, a "MM/DD/YY" type of date is produced. |
ERR=lineref | Branch to be taken if an error occurs during execution. |
PRO/5 recognizes several format indicators that all begin with a "%", followed by a letter indicating which component of the date/time to insert (the portion of the date is substituted directly into str at the position in which its corresponding symbol appears):
Format | Description |
---|---|
%Y | Year |
%M | Month |
%D | Day |
%H | Hour (24-hour clock) |
%h | Hour (12-hour clock) |
%m | Minute |
%s | Second |
%p | AM/PM |
An optional modifier can follow format indicators to describe more specific information:
Modifier | Description |
---|---|
z | Zero-fill |
s | Short text |
l | Long text |
p | Packed number (in CHR() form) |
d | Decimal (default format) |
The following table provides examples of possible date combinations. Assume the date to be July 11, 1999 and the time to be 6:30 PM.
Format | Default | Packed Number | Decimal | Zero-fill | Short Text | Long Text |
---|---|---|---|---|---|---|
%Y | 1999 | CHR(99) | 1999 | 99 | 1999 | 1999 |
%M | 7 | CHR(7) | 7 | 07 | Jul | July |
%D | 11 | CHR(11) | 11 | 11 | Sun | Sunday |
%H | 18 | CHR(18) | 18 | 18 | 18 | 18 |
%h | 6 | CHR(6) | 6 | 06 | 6 | 6 |
%m | 30 | CHR(30) | 30 | 30 | 30 | 30 |
%s | 0 | CHR(0) | 0 | 00 | 0 | 0 |
%p | PM | (N/A) | (N/A) | (N/A) | (N/A) | (N/A) |
Notice that the "s" and "l" formats of the day (%D)
give the day of the week.
The default format as well as the text used for month and day names may
be developer-assigned through the STBL() function. See the STBL
Formats section in the User's Reference
Guide for additional information.
DATE(-1) returns a null value.
Dates prior to the adoption of the Gregorian calendar are not historically
meaningful. Countries adopted the Gregorian calendar at various times
starting as early as October 15, 1582 (October 5 on the Julian calendar).
Great Britain and its colonies, including the territory that was to become
the USA, converted to the Gregorian calendar on September 14th, 1752 (September
3 on the Julian calendar). Some countries did not adopt the Gregorian
calendar until well into the 20th century.
Examples
Example 1
The following is the most simple form and prints the current date:
PRINT DATE(0)
Example 2
The following prints the message: "The current year is ", followed by the current year in four digits.
PRINT DATE(0:"The current year is %Y")
Example 3
The following prints a date in "MM/DD/YY" format (requiring the zero-fill operation):
PRINT DATE(0:"%Mz/%Dz/%Yz")