Before running a calculation you must first find out what rate your brokerdealer is charging to borrow money. The broker should be able to answer this question. Alternatively, the firm's website may be a valuable source for this information, as should account confirmation statements and/or monthly and quarterly account statements. In any case, once the rate being charged is readily known, grab a pencil, a piece of paper and a calculator and you will be ready to figure out the total cost.
Suppose you want to borrow $30,000 to buy a stock that you intend to hold for a period of 10 days.
In order to calculate the cost of borrowing simply:
Take the amount of money being borrowed and multiply it by the rate being charged:
$30,000 x .06 (6%) = $1,800
Then take the resulting number and divide it by the number of days in a year. The brokerage industry typically uses 360 days  not 365:
$1,800 / 360 = 5
Next, multiply this number by the total number of days you have borrowed, or expect to borrow, the money on margin:
5 x 10 = $50.
Using this example, it costs $50 to borrow $30,000 for 10 days.
To learn more about margin, see the Margin Trading tutorial.
RELATED FAQS

Why would I need total debt to total assets represented as a ratio, as opposed to ...
Learn why having the relationship between a company's total debt and its total assets is more valuable when expressed as ... 
How does a company's capitalization structure affect its profitability?
Learn about capitalization structure and how the combination of debt and equity a company uses to fund operations can affect ... 
How should investors interpret unlevered beta?
Learn what unlevered beta is, how it is calculated, and how investors can interpret the unlevered betas of companies within ... 
Why does the Federal Reserve Board regulate which stocks can be bought on margin?
Find out why the Federal Reserve Board began regulating margin stock purchases in 1934 and why margin requirements do not ...

Open Trade Equity (OTE)
Open trade equity (OTE) is the equity in an open futures contract. 
Leverage Ratio
Any ratio used to calculate the financial leverage of a company ... 
Ceded Reinsurance Leverage
The ratio of ceded insurance balances to policyholders’ surplus. ... 
David Einhorn
Known for his short selling strategy, activist investor David ... 
Short Call
A type of strategy regarding a call option, which is a contract ... 
Total DebttoCapitalization Ratio
An indicator that measures the total amount of debt in a company’s ...