Delphi Code to get the Next 6 months

This code is what i use to get the 6 months of the month. Including the parameter of February where we sometimes have a 28th or 29th day.

Just in case this code helps you, please drop us a line

Coffee Cup




   /* 2-16-2023 - CREATE SUMMARY */

  VYEAR = EXTRACT(YEAR FROM VDATEFROM);
  VMONTH = EXTRACT(MONTH FROM VDATEFROM);

  SAFROM1 = VYEAR || '-' || VMONTH || '-1';
  IF (VMONTH = 12) THEN
  BEGIN
    VMONTH = 1;
    VYEAR =  VYEAR + 1;
    SATO1 = VYEAR || '-' || VMONTH || '-1';
  END
  ELSE 
  BEGIN 
    VMONTH = VMONTH + 1;
    SATO1 = VYEAR || '-' || VMONTH || '-1';
  END
  SATO1 = SATO1 - 1;
  SAMONTH1 = 0;


  VDATE = SATO1 + 1;
  VYEAR = EXTRACT(YEAR FROM VDATE);
  VMONTH = EXTRACT(MONTH FROM VDATE);

  SAFROM2 = VYEAR || '-' || VMONTH || '-1';
  IF (VMONTH = 12) THEN
  BEGIN
    VMONTH = 1;
    VYEAR =  VYEAR + 1;
    SATO2 = VYEAR || '-' || VMONTH || '-1';
  END
  ELSE 
  BEGIN 
    VMONTH = VMONTH + 1;
    SATO2 = VYEAR || '-' || VMONTH || '-1';
  END
  SATO2 = SATO2 - 1;
  SAMONTH2 = 0;



  VDATE = SATO2 + 1;
  VYEAR = EXTRACT(YEAR FROM VDATE);
  VMONTH = EXTRACT(MONTH FROM VDATE);

  SAFROM3 = VYEAR || '-' || VMONTH || '-1';
  IF (VMONTH = 12) THEN
  BEGIN
    VMONTH = 1;
    VYEAR =  VYEAR + 1;
    SATO3 = VYEAR || '-' || VMONTH || '-1';
  END
  ELSE 
  BEGIN 
    VMONTH = VMONTH + 1;
    SATO3 = VYEAR || '-' || VMONTH || '-1';
  END
  SATO3 = SATO3 - 1;
  SAMONTH3 = 0;



  VDATE = SATO3 + 1;
  VYEAR = EXTRACT(YEAR FROM VDATE);
  VMONTH = EXTRACT(MONTH FROM VDATE);

  SAFROM4 = VYEAR || '-' || VMONTH || '-1';
  IF (VMONTH = 12) THEN
  BEGIN
    VMONTH = 1;
    VYEAR =  VYEAR + 1;
    SATO4 = VYEAR || '-' || VMONTH || '-1';
  END
  ELSE 
  BEGIN 
    VMONTH = VMONTH + 1;
    SATO4 = VYEAR || '-' || VMONTH || '-1';
  END
  SATO4 = SATO4 - 1;
  SAMONTH4 = 0;




  VDATE = SATO4 + 1;
  VYEAR = EXTRACT(YEAR FROM VDATE);
  VMONTH = EXTRACT(MONTH FROM VDATE);

  SAFROM5 = VYEAR || '-' || VMONTH || '-1';
  IF (VMONTH = 12) THEN
  BEGIN
    VMONTH = 1;
    VYEAR =  VYEAR + 1;
    SATO5 = VYEAR || '-' || VMONTH || '-1';
  END
  ELSE 
  BEGIN 
    VMONTH = VMONTH + 1;
    SATO5 = VYEAR || '-' || VMONTH || '-1';
  END
  SATO5 = SATO5 - 1;
  SAMONTH5 = 0;



  VDATE = SATO5 + 1;
  VYEAR = EXTRACT(YEAR FROM VDATE);
  VMONTH = EXTRACT(MONTH FROM VDATE);

  SAFROM6 = VYEAR || '-' || VMONTH || '-1';
  IF (VMONTH = 12) THEN
  BEGIN
    VMONTH = 1;
    VYEAR =  VYEAR + 1;
    SATO6 = VYEAR || '-' || VMONTH || '-1';
  END
  ELSE 
  BEGIN 
    VMONTH = VMONTH + 1;
    SATO6 = VYEAR || '-' || VMONTH || '-1';
  END
  SATO6 = SATO6 - 1;
  SAMONTH6 = 0;

  SAOTHERS = 0;
  SAUNPAID = 0;

  SUSPEND;

   /* 2-16-2023 - CREATE SUMMARY */
















    /* 2-16-2023 - CREATE SUMMARY */
    VDATE = NULL;
    IF (OCCHECK_DATE IS NOT NULL) THEN
    BEGIN
      VDATE = OCCHECK_DATE;
    END
    IF (OMDATE IS NOT NULL) THEN
    BEGIN
      VDATE = OMDATE;
    END

    IF (VDATE IS NOT NULL) THEN
    BEGIN
      IF ((VDATE >= SAFROM1) AND (VDATE <= SATO1)) THEN
        SAMONTH1 = SAMONTH1 + CP_INVAMT;
      ELSE
      IF ((VDATE >= SAFROM2) AND (VDATE <= SATO2)) THEN
        SAMONTH2 = SAMONTH2 + CP_INVAMT;
      ELSE
      IF ((VDATE >= SAFROM3) AND (VDATE <= SATO3)) THEN
        SAMONTH3 = SAMONTH3 + CP_INVAMT;
      ELSE
      IF ((VDATE >= SAFROM4) AND (VDATE <= SATO4)) THEN
        SAMONTH4 = SAMONTH4 + CP_INVAMT;
      ELSE
      IF ((VDATE >= SAFROM5) AND (VDATE <= SATO5)) THEN
        SAMONTH5 = SAMONTH5 + CP_INVAMT;
      ELSE
      IF ((VDATE >= SAFROM6) AND (VDATE <= SATO6)) THEN
        SAMONTH6 = SAMONTH6 + CP_INVAMT;
      ELSE
        SAOTHERS = SAOTHERS + CP_INVAMT;
    END

Leave a Reply

Your email address will not be published. Required fields are marked *