|  |     
    Fritz,
    
> I seem to remember that there was a discussion in one of the
> (old) ALL-IN-1 notesfiles but can't find the topic(s) anymore.
    
    In the note that you mention, I believe that Mr. Vickers posted a
    copy of a script from ALL-IN-1 EARS that does what you want.  I was
    going to post the note, but I couldn't find it either, so I'll re-post
    the script.  Credit goes to all of those fine folks with EARS...  ;')
    
    Jack
    
    
!+
!	EARS_COMPARE_DATE.SCP
!-
! This script is used to compare two dates and return the symbols
! #EARS_DAY_DIFF for the number of days, #EARS_HR_DIFF for the number of
! hours and #EARS_MIN_DIFF for the number of minutes
! Change the dates to NBS format
	date_convert #EARS_TMP1,#EARS_IN_DATE1,7
	date_convert #EARS_TMP2,#EARS_IN_DATE2,7
	decimal I
! Make sure we have valid dates
	.if #EARS_TMP1 eqs "" or #EARS_TMP2 eqs "" or #EARS_TMP2 lts #EARS_TMP1 -
            then .goto BAD_DATES
! Calculate the differences between the dates
	get oa$func='compute #EARS_YR_DIFF=' #EARS_TMP2:4 ' - ' #EARS_TMP1:4
	get oa$func='compute #EARS_MON_DIFF=' #EARS_TMP2:2:4 ' - ' #EARS_TMP1:2:4
	get oa$func='compute #EARS_DAY_DIFF=' #EARS_TMP2:2:6 ' - ' #EARS_TMP1:2:6
	get oa$func='compute #EARS_HR_DIFF=' #EARS_TMP2:2:8 ' - ' #EARS_TMP1:2:8
	get oa$func='compute #EARS_MIN_DIFF=' #EARS_TMP2:2:10 ' - ' #EARS_TMP1:2:10
	compute #EARS_DAY_DIFF=(((#EARS_YR_DIFF * 12) + #EARS_MON_DIFF) * 31) + #EARS_DAY_DIFF
! Since we expect review items to (complete somewhat) quickly, so this isn't
! a real bad way to do this, unless it takes many (+6) months to complete
.label EXACT_LOOP
	get oa$func='get CAL$SET_DATE:#EARS_CHK_DATE.%whole["' #EARS_IN_DATE1:11 ' +' #EARS_DAY_DIFF 'D"]'
	date_convert #EARS_TMP1,#EARS_CHK_DATE,7
	.if #EARS_TMP1:8 eqs #EARS_TMP2:8 -
            then .goto FOUND
	compute #EARS_DAY_DIFF=#EARS_DAY_DIFF - 1
	.if #EARS_DAY_DIFF ge 0 -
            then .goto EXACT_LOOP
! We have some bad dates, so let the user know
	.goto BAD_DATES
! Now that we know the number of days, let's figure out the hours and
! minutes, and adjust the days as necessary.
.label FOUND
	.if #EARS_MIN_DIFF lt 0 -
            then compute #EARS_MIN_DIFF=60 + #EARS_MIN_DIFF\-
                 compute #EARS_HR_DIFF=#EARS_HR_DIFF - 1
	.if #EARS_HR_DIFF lt 0 -
            then compute #EARS_HR_DIFF=24 + #EARS_HR_DIFF\-
                 compute #EARS_DAY_DIFF=#EARS_DAY_DIFF - 1
! Get rid of the blank lines output by the CAL$SET_DATE func
	oa$msg_purge
	get OA$STATUS=1
	.exit
.label BAD_DATES
! Get rid of the blank lines output by the CAL$SET_DATE func
	oa$msg_purge
	get #EARS_DAY_DIFF=#EARS_HR_DIFF=#EARS_MIN_DIFF="**"
	get OA$STATUS=0
	.exit
!
!  Copyright (c) Digital Equipment Corporation, 1991,
!  All Rights Reserved.  Unpublished rights reserved
!  under the copyright laws of the United States.
!
!  The software contained on this media is proprietary
!  to and embodies the confidential technology of
!  Digital Equipment Corporation.  Possession, use,
!  duplication or dissemination of the software and
!  media is authorized only pursuant to a valid written
!  license from Digital Equipment Corporation.
!
!  RESTRICTED RIGHTS LEGEND   Use, duplication, or
!  disclosure by the U.S. Government is subject to
!  restrictions as set forth in Subparagraph (c)(1)(ii)
!  of DFARS 252.227-7013, or in FAR 52.227-19, as
!  applicable.
!
 | 
|  | 
	The following example illustrates the use of a BASIC
program  --  DATE_DIFF.BAS  --  that can be invoked as a site defined
function, and which calls the internal
ALL-IN-1 routine that performs this date calculation.
 90 sub oax$date_diff ( cmd_line$ )
!  Enables user to do: 
!  <DATE_DIFF "05-JAN-1992","01-JAN-1992","1 00:00", #RESULT
!  in order to obtain the difference (in specified units)
!  between the two dates.
!
!  Units are calculated based on the third argument.
!  In this example, #RESULT will be the difference, in days,
!  between the two dates specified.
!
!  Use Customization Management to add a new site defined 
!  function called DATE_DIFF in Application Area OA (or
!  name and area of your choice).
!
100   EXTERNAL INTEGER FUNCTION  &
       oa$sym_get_symbol (String by DESC, String by DESC ), &
       oa$sym_make_symbol (String by DESC, String by DESC ), &
       oa$date_diff (double by REF, double by REF, String by DESC), &
       oa$date_binary (double by REF , String by DESC)
120   declare double enddate 
130   declare double startdate 
	
140   cmdline$ = cmd_line$ 
150   x% = pos (cmdline$,",", 1%)
155   if x% = 0 then goto 350
160   startdate$ = left$( cmdline$,x%-1)
170   cmdline$ = right$(cmdline$, x%+1)
180   x% = pos (cmdline$,",", 1%)
185   if x% = 0 then goto 350
190   enddate$ = left$( cmdline$,x%-1)
200   cmdline$ = right$(cmdline$, x%+1)
210   x% = pos (cmdline$,",", 1%)
215   if x% = 0 then goto 350
220   units$ = left$( cmdline$,x%-1)
230   result$ = right$(cmdline$, x%+1)
235   if result$ = "" or startdate$ = "" or enddate$ = "" &
         or units$ = "" then goto 350        
270   call oa$sym_get_symbol ( startdate$,start_date$)
275   if start_date$ = "" then goto 350
280   call oa$sym_get_symbol ( enddate$,end_date$)
285   if end_date$ = "" then goto 350
290   call oa$sym_get_symbol ( units$,unit$)
295   if unit$ = "" then goto 350
	
300   call oa$date_binary (startdate, start_date$)
310   call oa$date_binary (enddate, end_date$)
320   x% = oa$date_diff (startdate ,enddate ,unit$)
330   diff$ = num1$ ( x% )
	
340   call oa$sym_make_symbol ( result$, diff$)
 
350   end sub
 |