CDS055

Date Conversion Routine

Last Revised: 11/16/15

This called routine is used to convert a date to different display formats.  For web applications, see CDW055 which formats dates entered during a web form.

Calling Format:

CALL "CDS055", DIN$, DAT$[ALL]

You do not need to pre-dimension DAT$[ ] before calling.  Excellware recommends that all dates be stored in julian format.  If using templates, store julian dates in a U(3) format otherwise use an N(7) format.

Note that Dynamo Tools use a slightly different convention for an unassigned date field than the BBx/BBj DATE() function.  Dynamo Tools considers a zero value julian date field as unassigned.  BBx treats a zero value julian date as today's date, and uses a negative one value to mean unassigned.  Dynamo Tools uses zero as unassigned so that dimensioning a string template that contains date fields does not require setting each date field to negative one.

CDS055 Arguments
DIN$ the input date to be converted, which can be in any of the following formats:
 

3 character julian date in U(3) format

4 character date in YYYYMMDD format packed using PCK()

5 or 6 character Microsoft serial number date

6 character date in YYMMDD format

6 character date in MAS90 format

7 digit BBx julian date

8 character date in MM/DD/YY format, or MMDDYYYY format, or YYYYMMDD format

10 character date in either MM/DD/YYYY or YYYY-MM-DD format

CDS055 will automatically determine the input format used.

If the input date DIN$ is passed as null, then today's date is used as the input date.  This is the only situation where today's date is used.

If the input date DIN$ is not any of the formats listed, or if the input date DIN$ is all blank or all zero's, or if DIN$ is not a valid date, then no error will be generated and the output array will be all null strings.

DAT$[ALL] Output string array assigned using the formats shown below.
DAT$[0]MM/DD/YY
DAT$[1]YYMMDD
DAT$[2]BBx Julian format (7 digits)
DAT$[3]Day of week - long: Monday
DAT$[4]Day of week - short: Mon
DAT$[5]Display format - long: May 3, 1990
DAT$[6]MAS90 format which is a modified YYMMDD where YY is coded to permit years beyond 2000. 1996 for example is represented by "?,"
DAT$[7]Microsoft serial number date masked with ###### where 1 is 1/1/1900
DAT$[8]YYYYMMDD packed into 4 characters using PCK()
DAT$[9]YYYYMMDD
DAT$[10]YYYY-MM-DD typically used with SQL and JSON
DAT$[11]MM/DD/YYYY

Y2K Considerations: This program as well as all Dynamo Tools, uses a sliding window to determine the full 4 digit year. Since the input routine does not allow for entry of the full 4 digit year, the full 4 digit year must be assumed.

The rule that is used on BBx Progression 4, was a fixed window, where any year less than 50, is considered 20xx, and any year 50 to 99 was considered 19xx.

The PRO/5 and BBj version of these programs permit entries of years up to 9 years in the future, and 90 years in the past. For example, if today is 02/14/99, then 2 digit years of 00,01,02,03,04,05,06,07 and 08 will be considered 20xx.  All others are considered 19xx.  If today is 02/14/2010, then 2 digit years of 00 through 19 will be considered 20xx.  All others are considered 19xx.

Note that it is only possible to convert a date prior to 90 years ago, or after 9 years from this year, using the Julian format or one of the formats that include a 4 digit year.

Examples
>CALL "CDS055","04/15/05",DAT$[ALL]
>WRITE DAT$[ALL]
04/15/05
050415
2453476
Friday
Fri
April 15, 2005
?50415
38457
4%$/
20050415
2005-04-15
04/15/2005
>CALL "CDS055",STR(JUL(2004,12,31)),DAT$[ALL]
>WRITE DAT$[ALL]
12/31/04
041231
2453371
Friday
Fri December 31, 2004
?41231
38352
4$,?
20041231
2004-12-31
12/31/2004
>CALL "CDS055","20050315",DAT$[ALL]
>WRITE DAT$[ALL]
03/15/05
050315
2453445
Tuesday
Tue March 15, 2005
?50315
38426
4%#/
20050315
2005-03-15
03/15/2005

>CALL "CDS055","050228",DAT$[ALL]
>WRITE DAT$[ALL]
02/28/05
050228
2453430
Monday
Mon February 28, 2005
?50228
38411
4%"<
20050228
2005-02-28
02/28/2005