Gross margin for the quarter was 34.1 percent compared with the prior year period margin of 28.8 percent. For the first nine months of 2012, gross margin was 33.3 percent compared with 30.9 percent in the prior year period. Gross margin improvement over the prior year for the quarter and first nine months driven by lower warranty costs in both the Energy and Water segments, which positively impacted gross margin by 5.4 percentage points in the quarter and 1.9 percentage points in the nine month period. Additionally, benefits from our restructuring actions and manufacturing efficiencies offset the impact of decreased volumes.
GAAP operating expenses were $126 million in the quarter and $420 million for the first nine months of 2012, compared with $674 million and $953 million in the same periods of 2011. The 2011 periods included a non-cash goodwill impairment charge of $540 million. The remaining operating expenses for the quarter decreased $8 million compared with the prior year due to a favorable impact of $9 million from changes in foreign currency rates, lower intangible asset amortization and restructuring costs offset by higher sales and marketing and product development costs. For the nine month period, the remaining operating expenses increased $7 million compared with the 2011 period due to increased global sales and marketing activity and product development efforts, partially offset by a favorable impact of $20 million from foreign exchange rate changes. GAAP operating income for the quarter and first nine months of 2012 was $46 million and $132 million, compared with an operating loss of $497 million and $399 million in the respective 2011 periods. Changes in foreign currency rates reduced operating income $1 million in the quarter and $3 million in the first nine months of 2012.
Net interest expense was $2.3 million for the quarter and $6.9 million for the nine month period compared with $10.6 million and $33.7 million in the same periods last year. The decrease in net interest expense was due to a reduced principal balance and lower effective interest rates due to a refinancing of bank debt in August 2011.