Relief may be in sight for bankers struggling to survive bad farm loans.

Two powerful senators said yesterday they expect to get a bill to the Senate floor within weeks that would allow commercial banks to use the same special bookkeeping rules that are used to prop up ailing savings and loans.

The bookkeeping technique -- known as deferring loan losses -- would allow bankers to stretch over several years the write-off of bad farm loans. It sharply deviates from generally accepted accounting principles used by most companies, which deduct losses immediately.

The same accounting technique, which now keeps hundreds of ailing S&Ls in business, has been widely criticized for masking the severity of the S&L industry's problems.

Of the 120 bank failures last year, 62 were farm banks. As many as 1,700 banks, most of them small community institutions, could benefit from a farm-bank credit bill.

Senate Majority Leader Robert J. Dole (R-Kan.) and Senate Banking Committee Chairman Jake Garn (R-Utah) said at congressional hearings yesterday that they would work to get a speedy vote for a credit-relief bill with bipartisan support.

Garn and Dole said the bill probably would be a modified form of a measure that has been introduced by Alan Dixon, (D-Ill.).

Widespread endorsement for the bill could pave the way for similar relief for commercial banks suffering from bad energy and real estate loans, congressional sources said.

Hint of widespread acceptance reflects growing worry about the health of federal deposit insurance agencies. The Federal Deposit Insurance Corp., which offers federal insurance for bank deposits up to $100,000, had reserves of $18 billion at the end of 1985. The agency is expected to release today an accounting of how much money it lost as the result of last year's failures.

If the measure passes the Senate and the House and becomes law, its success will depend on market conditions, said Mark Drabenstott, research officer and economist for the Federal Reserve Bank of Kansas City, Mo.

"If the farm market rebounds, then deferred loan loss makes sense," Drabenstott said. "But if the market only levels out and bounces for a while at the bottom, then, with deferred loan losses, you may only be postponing the inevitable." He predicted that the farm economy will not pick up for at least two years.

Dole, Garn and Dixon, all from farm states, face elections this year and feel pressure to pass a credit-relief bill for farm banks.

Regulators define a farm bank as one that has made at least 25 percent of its loans to farm-related ventures.

In December, Congress passed the Farm Credit Amendments Act, which promises emergency aid from the U.S. Treasury to the Farm Credit System, a group of lending institutions that are federally chartered and owned by the farmers who borrow from them. The Farm Credit System held $59 billion of the $209 billion in loans owed by farmers at the end of 1985. Commercial banks, the system's main competitors, held $47 billion.

"We did address the Farm Credit System reforms, and it is incumbent upon us now to likewise address the commercial-bank side of the equation," Dole said in a surprise appearance at the Senate Banking Committee hearings yesterday.

If brought to the Senate floor, the bill would be the second attempt in six months to get a bill passed to provide credit relief for banks with farm loans. Dixon's first bill was defeated by a narrow vote. It extended the deferred-loan-loss provision for 30 years, which many lawmakers and regulators felt was too long. Dixon's bill now extends the rule for 10 years, and that is likely to drop to three years or five years by the time the bill is presented for a vote.

"In my view, there is much to be said . . . for allowing a bank to amortize its loan losses over a five-year period," Dole said. "The experts can argue about the technical aspects, but it seems to me it simply provides a bank some breathing room until economic conditions improve."

The unique accounting measures essentially puff up on paper a bank's basic funding reserves to meet federal regulations, keep its doors open and avoid draining money from the FDIC.

"We endorse the Dixon bill," said John Lewis of the American Farm Bureau Federation, which represents 3.4 million farm families. "Deferring loan losses helps banks help farmers. It's not a bailout."

The bill, which is likely to be introduced as early as next week, would allow loans to be stretched out for at least three years, possibly as many as 10 years, congressional aides said. In its present form, it allows the stretch-out only on agricultural-related loans and only by farm banks with assets of $250 million or less.

Despite criticism for credit relief by the Federal Reserve Board and the Treasury, the proposal has wide support. The American Bankers Association and the Independent Bankers Association of American, two powerful industry lobby groups, back it.

Two weeks ago, the FDIC said that, if Congress decides some form of change in policy is appropriate, then the FDIC prefers loan loss deferrals over a period of three to five years rather than net-worth certificates.

Although not an endorsement, the FDIC's statement represents a sigificant change from a year ago, when the agency opposed allowing banks to use out-of-the-ordinary accounting rules.

At the hearings yesterday, Assistant Treasury Secretary Charles O. Sethness objected to deferred-loan-loss accounting but, when pressed, said the administration would not try to block adoption of such methods.

Fed Chairman Paul A. Volcker, however, said in a letter to Garn last week, that deviations from generally accepted accounting rules could "confuse the public and impair the usefulness and credibility of regulatory financial statements."

In an apparent reference to extending similar accounting rules to banks heavily involved in bad energy, real estate and foreign loans, Volcker's letter said, "Government-backed restructuring for loans also raised questions about the treatment of other broad classes of troubled credit at U.S. banks and other lenders."

The statement goes head-to-head with Dole and the bank lobby groups. "We all know what has happened to oil prices since January and the effect that will have on banks," Dole said.

"I know . . . we can't save every loan or every bank. . . . But what we can do is provide some limited aid, which will have a stabilizing effect on the financial industry as a whole," Dole added.