# SYD 函數

SYD (、 salvage、 life， period)

SYD 函數語法具有以下引數：

Life period 自 變數必須以相同的單位表示。 例如，如果 生活以 月表示， 則期間 也必須以月份表示。 所有引數都必須是正數。

## 查詢範例

SELECT SYD ([LoanAmount],[LoanAmount]*.1,20,2) AS Expr1 FROM FinancialSample;

SELECT SYD ([LoanAmount]，0，20，3) AS SLDepreciation FROM FinancialSample;

## VBA 範例

``` Dim Fmt, InitCost, SalvageVal, MonthLife, LifeTime, DepYear, PDeprConst YEARMONTHS = 12 ' Number of months in a year.Fmt = "###,##0.00" ' Define money format.InitCost = InputBox("What's the initial cost of the asset?")SalvageVal = InputBox("What's the asset's value at the end of its life?")MonthLife = InputBox("What's the asset's useful life in months?")Do While MonthLife < YEARMONTHS ' Ensure period is >= 1 year. MsgBox "Asset life must be a year or more." MonthLife = InputBox("What's the asset's useful life in months?")LoopLifeTime = MonthLife / YEARMONTHS ' Convert months to years.If LifeTime <> Int(MonthLife / YEARMONTHS) Then LifeTime = Int(LifeTime + 1) ' Round up to nearest year.End If DepYear = CInt(InputBox("For which year do you want depreciation?"))Do While DepYear < 1 Or DepYear > LifeTime MsgBox "You must enter at least 1 but not more than " & LifeTime DepYear = CInt(InputBox("For what year do you want depreciation?"))LoopPDepr = SYD(InitCost, SalvageVal, LifeTime, DepYear)MsgBox "The depreciation for year " & DepYear & " is " & Format(PDepr, Fmt) & "." ```

×