	SUBROUTINE ENDDATE (BIN_DATE,LAST_DAY)
	IMPLICIT INTEGER(A-Z)
	INTEGER*4 IDATE(3),NEXT_FIRST,LAST_DAY,CUR_DAY,SAVCURDAY
	INTEGER*4 BIN_DATE(2),LASBIN_DATE(2)
	CHARACTER*11 CHAR_DATE
C
	IDATE(1) = 0
	IOPT = 1
	CALL CVDATE(IDATE,BIN_DATE,CHAR_DATE,IOPT)
	SAVCURDAY = IDATE(1)
	CALL LIB$DAY(CUR_DAY,BIN_DATE)

	IDATE(1) = 1
	IDATE(2) = IDATE(2) + 1
	IF (IDATE(2).EQ.13) THEN
	IDATE(3) = IDATE(3) + 1
	IDATE(2) = 1
	END IF
C
	CHAR_DATE = '           '

	LASBIN_DATE(1) = 0
	LASBIN_DATE(2) = 0
	IOPT = 3
	CALL CVDATE(IDATE,LASBIN_DATE,CHAR_DATE,IOPT)
	CALL LIB$DAY(NEXT_FIRST,LASBIN_DATE)

	LAST_DAY = NEXT_FIRST - CUR_DAY 

	LAST_DAY = SAVCURDAY + LAST_DAY-1

	RETURN
	END

