For the purposes of this chapter a cause of action for the foreclosure of a mortgage shall be deemed to have accrued at the last date of the maturity of the debt or other obligation secured thereby, as stated in, or as ascertainable from the record of such mortgage or in an extension thereof duly executed and recorded, and if no date for any maturity be stated therein or be ascertainable therefrom then after fifteen years from the date of said mortgage.
SDCL 15-2-5