Software development, photography, jokes, ....

Sites by me

 
tas-logoTransportation Administration System
snoezelkussen-logo-kleinstSnoezelkussens voor verstandelijk gehandicapten
ikzoekeenbegeleider-logoBegeleiders voor gehandicapten
Laat uw hond het jaarlijkse vuurwerk overwinnen
logo 50x50Hey Vos! Je eigen naam@vos.net emailadres?
Kunst in huis? Nicole Karrèr maakt echt bijzonder mooie dingen
nettylogo2Kunst in huis? Netty Franssen maakt ook bijzonder mooie dingen
Salarisadministratie en belastingadvies bij De Zaak Loont
Zutphense Bomenstichting

Hosting Favorites

 
ANU Internet Services
XelMedia .internet Services
register.com

Blogroll

 
Bomenstichting
LassoSoft
MacFreak
Quality that computes
The Economy of Motion
Wheel 2.0
IntrAktv



Website Hosting bij Xel Media

Marc's Place

 

E$CLCDAT - Date Calculations and Verification

(also available for the Lasso programming language at TagSwap: http://tagswap.net/mv_clcdat)

Start Command

call e$clcdat (<msgid> <date1> [date2] <option> <result>)

Call Parameters

Explanation of abbriviations:
CC = Century
YY = Year
MM = Month
DD = Day
WW = Week
DDD = Day number
 
[ ] = Optional
 
Furthermore, all dates are expected in the form CCYYMMDD, except when explicitly statet otherwise.
 
Date variables are all alphanumeric so E$CLCDAT can also be called by CL-programs.
 
date1 (a8)
A date in the form [CC]YYMMDD, a week number in the form CCYYWW, a day number in the form CCYYDD, etc.
 
Use the variable DATP2 (alphanumeric) or DATIN2 (numeric) from the /COPY member DS_E$DATE
 
date2 (a8)
A date in the form [CC]YYMMDD, a number, control codes, etc.
 
Use the variable DATP3 (alphanumeric) or DATIN3 (numeric) from the /COPY member DS_E$DATE
 
option (a2)
An instruction for the routine what calculation to perform.
 
Use the variable DATP4 from the /COPY member DS_E$DATE
 
The following options can be applied:
 
AD Add Days

Adds the number of days in date2 to a date1 date [CC]YYMMDD.

 
AW Add Work Days

Adds the number of work days in date2 to a date1 date [CC]YYMMDD and adds the missing weekends itself.

 
DF Difference

Calculates the difference in days between an old date [CC]YYMMDD in date1 and a younger date [CC]YYMMDD in date2. When you swap the dates, the result will be negative.

 
DN Day to Number

Converts a date [CC]YYMMDD in date1 to a day number CCYYDDD.

 
DS Difference Separated

Calculates the difference in days, months and years between an old date [CC]YYMMDD in date1 and a younger date [CC]YYMMDD in date2. When you swap the dates, the result will be negative.
 
The difference is returned as a D18 field, which contains 3x6 positions: YYYYYY MMMMMM DDDDDD (years, months and days).

 
EX Exit

The program normally exits without setting indicator LR to on. If you want to release E$CLCDAT from memory, call E$CLCDAT with this option.

 
FS From Screen

Turns date1 around from DDMM[CC]YY to CCYYMMDD. When it's a 6-digit date, the missing century is automatically added.

(Meant for conversion from 6-digit screen field to 8-digit database field)

 
LD Last Day

Returns the last day number of the month (DD = 28/29, 30 or 31) of a date1 date [CC]YYMMDD. The passed date is not validated so if you pass an invalid month number, the result will be zero.

 
ND Number to Day

Converts a day number CCYYDDD in date1 to a date CCYYMMDD.

 
SD Subtract Days

Subtracts the number of days in date2 from a date1 date [CC]YYMMDD.

 
TA To Alpha

Converts a date1 date [CC]YYMMDD to its alphanumeric equivalent DD M[MMMMMMMM] CCYY or DD-MM-[CC]YY. The length of the name of the month is controlable through date2, also whether the name should be uppercased or not:

  • The rightmost position controls whether the name of the month should be uppercased (1) or not (0). This position can also be used to signal (9) that the date should be in plain numerical form, separated by a minus sign.
  • The second position from the right defines the length of the name of the month that should be returned when the rightmost position is not equal to 9. Defaults to 3; maximum length is, of course, 9.

To illustrate the explanation, here are some examples:

  • date1 = 20020227, date2 = 00000000
    Result: "DD Mmm JJJJ" (27 Feb 2002)
  • date1 = 20020227, date2 = 00000090
    Result: "DD Mmmmmmmmm JJJJ" (27 Februari 2002)
  • date1 = 20020227, date2 = 00000009
    Result: "DD-MM-JJJJ" (27-02-2002).
 
TD Turn Date

Turns date1 around:

  • DDMMYY -> YYMMDD
  • YYMMDD -> DDMMYY
  • CCYYMMDD -> DDMMCCYY
 
TS To Screen

Turns date1 around from CCYYMMDD to DDMMYY.

(Meant for conversion from 8-digit database field to 6-digit screen field)

 
VL Validate

Validates a [CC]YYMMDD in date1. At this point, if CC is missing, the current century will be added to the workfields so internal calculations are performed correctly.

This routine is used by most previously named options, so don't call it yourself unless you really want it. See here for possible errors during validation.

 
VN Validate Number

Validates a week number (CCYYWW) (weeks 1 through 53) in date1 or a day number (CCYYDDD) (days 1 through 365/366) in date1.

This routine is used internally by other routines. You can use it yourself if you like to check the week number a user has entered. See here for possible errors during validation.

Century is NOT added if it's not passed.

 
WD Week Day

Calculates the name of the day and/or the number of the day in the week from date1 [CC]YYMMDD or returns the name of the day from a day number(1 thru 7) in the week in date1. The length of the name and whether the name should be uppercased or not, can be controlled through date2:

  • The rightmost position ontrols whether the name of the day should be uppercased (1) or not (0).
  • The second position from the right defines the length of the name of the day that should be returned. Defaults to 1; maximum length is, of course, 9.

So here are some examples:

  • date1 = 20020227, date2 = 00000030
    Result: "Woe" in the first three positions of <result> and "03" in the last two positions.
  • date1 = 00000004 date2 = 00000041
    Result: "DOND" in the first four positions of <result> and "04" in the last two positions.
 
WK Week

Calculates a week number (CCYYWW) from date1 [CC]YYMMDD.

 
WM Week Monday

Calculates the day number CCYYDDD of the monday of the week CCYYWW in date1.

 
** Systemdate

Returns the systemdate as CCYYMMDD.

 

Return Parameters

msgid (a7)
Errors returned in <msgid> are:
 
DAT0001: E$CLCDAT - Parameter 2 is empty.
DAT0002: Invalid date.
DAT0003: Invalid week.
DAT0004: Invalid day number.
DAT0010: E$CLCDAT - Invalid Option.
 
These error messages can be found in message file E$ERRMSG in E$LIB. You can also create them in your own error message file. E$CLCDAT does NOT SEND the message! It merely returns the ID so you can detect a faulty date or so.
 
Use the variable DATP1 from the /COPY member DS_E$DATE
 
result (a20)
Alphanumeric results are left justified. Numeric results are right justified with leading zeros. Negative results will be converted to zoned character in the resultfield: -27 is "2P". But, when you MOVE the result in a numeric field, it will be a negative value again.
 
Use the variable DATP5 from the /COPY member DS_E$DATE

Examples

Here's one coding example where 20 days are added to 26 december 2001:

CALL E$CLCDAT
PARM           DATP1
PARM 20011226  DATIN2
PARM 20        DATIN3
PARM 'AD'      DATP4
PARM           DATP5

Examples of possible results are shown in the picture below:


Go to download page
© 1997- Marc Vos (and others) Contact Me