Net income (loss). Our net income was $4.6 million for the three months ended June 28, 2024, as compared to a net income of $0.4 million for the three months ended June 30, 2023. The increase in net income was primarily attributable to the increase in income from operations combined with the decrease in total other expense, net and the lower effective tax rate.
Six Months Ended June 28, 2024 Compared to Six Months Ended June 30, 2023
Contract revenue. Consolidated contract revenue increased $41.8 million, or 18.9%, in the six months ended June 28, 2024, compared to the six months ended June 30, 2023, due to incremental revenues in both our Energy segment and our Engineering and Consulting segment.
Contract revenue in our Energy segment increased $37.3 million, or 20.6%, in the six months ended June 28, 2024, compared to the six months ended June 30, 2023, primarily as a result of increases in construction management and utility program revenues.
Contract revenue in our Engineering and Consulting segment increased $4.5 million, or 11.2%, in the six months ended June 28, 2024, compared to the six months ended June 30, 2023, primarily due to increased demand for services provided to our clients.
Direct costs of contract revenue. Direct costs of consolidated contract revenue increased $27.5 million, or 19.7%, for the six months ended June 28, 2024, compared to the six months ended June 30, 2023, primarily as a result of the increase, and change of mix, in contract revenues as described above. As a percentage of contract revenue, direct salaries and wages decreased to 17.1% in the six months ended June 28, 2024 from 18.8% in the six months ended June 30, 2023, while subcontractor services and other direct costs increased to 46.3% in the six months ended June 28, 2024 from 44.2% in the six months ended June 30, 2023.
Direct costs of contract revenue in our Energy segment increased $25.9 million, or 21.4%, for the six months ended June 28, 2024, compared to the six months ended June 30, 2023. Direct costs of contract revenue for the Engineering and Consulting segment increased $1.6 million, or 8.6%, in the six months ended June 28, 2024, compared to the six months ended June 30, 2023.
Subcontractor services and other direct costs increased by $24.1 million, or 24.5%, in the six months ended June 28, 2024, compared to the six months ended June 30, 2023, primarily due to the increase in construction management revenues, which utilize a higher percentage of material cost and installation subcontracting. Salaries and wages increased by $3.4 million, or 8.3%, in the six months ended June 28, 2024, compared to the six months ended June 30, 2023, primarily as a result of the increases in contract revenue as described above.
Gross Profit. Gross profit increased 17.5% to $96.2 million, or 36.5% gross margin, for the six months ended June 28, 2024, compared to gross profit of $81.9 million, or 37.0% gross margin, for the six months ended June 30, 2023. The decrease in our gross margin was primarily driven by changes in the mix of revenues as described above.
General and administrative expenses. G&A expenses increased $9.0 million, or 11.9%, in the six months ended June 28, 2024, compared to the six months ended June 30, 2023. G&A expenses consisted of an increase of $5.4 million in the Energy segment combined with an increase of $3.3 million in the Engineering and Consulting segment, and an increase of $0.3 million in unallocated corporate expenses.
Within G&A expenses, the increase of $7.8 million in salaries and wages, payroll taxes and employee benefits, combined with the increase of $1.9 million in other general and administrative expenses, and the increase of $0.5 million in stock-based compensation was partially offset by a decrease of $1.1 million in depreciation and amortization. The increase in salaries and wages, payroll taxes and employee benefits was primarily due to an increase in incentive compensation, consistent with the improvement in operating profit, and higher fringe benefit costs. The increase in other general and administrative expenses was primarily due to increased professional service fees and computer-related expenses. The increase in stock-based compensation expenses was primarily related to new stock grants to current