Logo

DB

Updated 2023-10-09 12:59:46.553000

Syntax

SELECT [westclintech].[wct].[DB] (
   <@Cost, float,>
 ,<@Salvage, float,>
 ,<@Life, float,>
 ,<@Per, int,>
 ,<@MonthsInFirstYear, int,>)

Description

Use the scalar function DB to calculate the depreciation of an asset for a specified period using the fixed-declining balance method.

Arguments

@Life

the estimated useful life of the asset. @Life is an expression of type float or of a type that can be implicitly converted to float.

@MonthsInFirstYear

the number of months in the first year. If NULL, it is assumed to be 12. @MonthsInFirstYear is an expression of type int or of a type that can be implicitly converted to int.

@Salvage

the estimated value of the asset at the end of the depreciation period. @Salvage is an expression of type float or of a type that can be implicitly converted to float.

@Cost

the total acquisition cost of the asset. @Cost is an expression of type float or of a type that can be implicitly converted to float.

@Per

the period for which the depreciation is being calculated. To obtain meaningful results, the calendar unit used for period and the calendar unit used for life should be the same. If depreciation for a month is being calculated then the life should be expressed as a number of months. If depreciation for a quarter is being calculated, then the life should be expressed in quarters. @Per is an expression of type int or of a type that can be implicitly converted to int.

Return Type

float

Remarks

The fixed-declining balance method computes depreciation at a fixed rate. DB uses the following formulas to calculate depreciation for a period:

(@Cost - total depreciation from prior periods) * rate

Where:

rate = 1 - ((@Salvage / @Cost) ^ (1 / @Life)), rounded to three decimal places.

Depreciation for the first and last periods is a special case. For the first period, DB uses this formula:

@Cost * rate * @MonthsInFirstYear / 12.

For the last period, DB uses this formula:

((@Cost - total depreciation from prior periods) * rate * (12 - @MonthsInFirstYear)) / 12.

Examples

SELECT wct.DB(600000, 0, 4, 1, 3);

Here is the result set.

{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"150000"}]}