Contract revenue in our Energy segment increased $21.7 million, or 11.9%, in the six months ended June 30, 2023, compared to the six months ended July 1, 2022, primarily as a result of increases in construction management revenues, software licensing, and planning and advisory consulting revenues. Contract revenue in our Engineering and Consulting segment increased $5.5 million, or 13.5%, in the six months ended June 30, 2023, compared to the six months ended July 1, 2022, primarily due to increased demand for services provided to our clients.
Direct costs of contract revenue. Direct costs of consolidated contract revenue increased $8.2 million, or 6.3% for the six months ended June 30, 2023, compared to the six months ended July 1, 2022, 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 from 20.6% in the six months ended July 1, 2022 to 18.8% in the six months ended June 30, 2023, while subcontractors services and other direct costs decreased from 47.0% in the six months ended July 1, 2022 to 44.2% in the six months ended June 30, 2023.
Direct costs of contract revenue in our Energy segment increased $5.8 million, or 4.8% for the six months ended June 30, 2023, compared to the six months ended July 1, 2022. Direct costs of contract revenue for the Engineering and Consulting segment increased $2.4 million, or 12.8%, in the six months ended June 30, 2023, compared to the six months ended July 1, 2022.
Subcontractor services and other direct costs increased by $6.6 million, or 7.2%, while salaries and wages increased by $1.6 million, or 4.0%, in the six months ended June 30, 2023, compared to the six months ended July 1, 2022, primarily as a result of the increases in contract revenue.
Gross Profit. Gross profit increased 30.1% to $81.9 million, or 37.0% gross margin, for the six months ended June 30, 2023, compared to gross profit of $63.0 million, or 32.4% gross margin, for the six months ended July 1, 2022. The increase in our gross margin was primarily driven by changes in the mix of revenues as described above combined with the absence of project startup costs for new utility programs that were incurred during the first half of fiscal year 2022 but did not recur in the first half of fiscal year 2023.
General and administrative expenses. G&A expenses increased $1.6 million, or 2.1%, in the six months ended June 30, 2023, compared to the six months ended July 1, 2022. G&A expenses consisted of an increase of $1.7 million in the Energy segment combined with an increase of $1.9 million in the Engineering and Consulting segment, partially offset by a decrease of $2.0 million in unallocated corporate expenses.
Within G&A expenses, the increase of $5.0 million in salaries and wages, payroll taxes and employee benefits was partially offset by a decrease of $2.2 million in stock-based compensation, a decrease of $0.9 million in other general and administrative expenses, and a decrease of $0.5 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 gross profit. The decrease in stock-based compensation expenses was primarily related to previously awarded stock grants reaching the end of their corresponding vesting periods, partially offset by new equity awards being issued at lower stock prices. The decrease in depreciation and amortization was primarily related to lower amortization of intangible assets from prior acquisitions.
Income (loss) from operations. Operating income was $6.5 million for the six months ended June 30, 2023, compared to an operating loss of $10.9 million for the six months ended July 1, 2022, as a result of the factors noted above.
Total other expense, net. Total other expense, net, increased $2.9 million, or 231.5%, for the six months ended June 30, 2023, compared to the six months ended July 1, 2022, primarily due to higher interest expense as a result of the increase in market interest rates which directly affected our variable interest rates under our Credit Facility.