project QadFinancials > class BFixedAssetDepreciation > method CalcLastDate

function returns date

Description

Calculates the last date of given calendar year and month.


Parameters


iiYearinputintegerYear
iiMonthinputintegerMonth
iiMonthPosinputintegerIndicaters what month do you want to get the last day of.
Supported values:
0 = last day of iiMonth
1 = last day of iiMonth + 1.


Internal usage


QadFinancials
method BFixedAssetDepreciation.APIDepreciationSimul
method BFixedAssetDepreciation.DepreciationMain


program code (program5/bfixedassetdepreciation.p)

/*iiYear and iiMonth are mandatory*/
if iiYear = 0 or
   iiYear = ? or
   iiMonth = 0 or
   iiMonth = ?
then return ?.

if iiMonthPos = ? 
then assign iiMonthPos = 0.

case iiMonthPos:
    /*get the last ady of the current month*/
    when 0
    then return date(/*Month*/
                if iiMonth >= 12 
                then 1 
                else iiMonth + 1, 
                /*Day*/
                1, 
                /*Year*/
                if iiMonth >= 12 
                then iiYear + 1 
                else iiYear) - 1.
    /*get the last day of the next month*/
    when 1
    then return date(/*Month*/
            if iiMonth = 11 
            then 1 
            else if iiMonth = 12 
            then 2 
            else iiMonth + 2, 
            /*Day*/
            1, 
            /*Year*/
            if iiMonth >= 11 
            then iiYear + 1 
            else iiYear) - 1.
    otherwise return ?.
end case.