In fixed income markets, professionals speak of a bond's clean price or dirty price. These are two quoting conventions that differ in whether or not they include accrued interest in a bond's quoted price.
In the evolution of the market value, we see two overlapping processes. One is a shark-tooth pattern that rises and suddenly drops every six months. This reflects the bond accruing interest and then paying it out in a coupon every six months. Each coupon is for USD 1.50, and that is the magnitude of each drop in market value. Integrated with this pattern is a gradual decline in market value over the first two years, followed by a gradual rise. This reflects, perhaps, evolution in interest rates and/or the credit quality of the issuer.
These two processes can be disaggregated. Consider Exhibit 2. It shows two graphs. The first reflects the bond's market value with the shark tooth pattern subtracted out. This is called the bond's clean price. The shark tooth pattern is shown in the second graph. It is the bond's accrued interest.
If we add the two graphs of Exhibit 2 together, we get the graph of Exhibit 1. We called the quantity depicted in Exhibit 1 the bond's market value, but another name for it is the bond's dirty price. Mathematically:
Traders tend to think of bonds in terms of their clean prices, and that is how they quote bond prices. This is because clean prices are more stable over time than dirty prices. When clean prices do change, it is for some economic reason, such as changes in interest rates or changes in the issuer's credit quality. Clean prices aren't cluttered by the semiannual rise and fall of interest accruing and being paid, as are dirty prices.
Of course, when a bond is bought or sold in the secondary market, it is the dirty price that is paid. That is the bond's market value—so bonds are quoted as clean prices but transact at dirty prices. For this reason, the dirty price is sometimes called the invoice price.
Because bonds are quoted as clean prices, dirty prices must be calculated by ascribing a value to accrued interest and adding it to the clean price. Conceptually, we should add the market value of accrued interest to the clean price. In most bond markets, coupons don't trade independently, so they have no observable market values. Accordingly, there are conventions for ascribing value to accrued interest. Generally, these treat coupons as accruing at simple interest:
To apply formula  correctly, you need to be aware of some or all of the following dates:
The coupon date is the date on which the coupon will be paid.
The last coupon date is the date on which the previous coupon was paid.
The settlement date is the date on which the traded bond actually exchanges hands and is paid for.
To calculate the numerator of , you calculate the number of days between the last coupon date and the settlement date. The manner in which you do so depends on the applicable convention. With an actual/actual convention, which applies with US Treasury bonds, you simply count the days. With a 30/360 convention, which applies with US corporate bonds, you count the days as if all months had 30 days.
Calculation of the denominator also depends on the applicable convention. With an actual/actual day count, you count the days between the past and upcoming coupon dates. If a 30/360 basis is used and coupons are paid semiannually the denominator is simply set equal to 180.
If a bond trades on or after the ex-coupon date, the seller keeps the coupon. However, the buyer will own the bond during a small fraction of the coupon period. The seller must pay him the interest that accrues during that brief period. This is sometimes called negative accrued interest, because the interest is subtracted from the bond price. Formula  is not used. The bond's dirty price is set equal to its clean price minus the quantity
If you look very closely at the second graph in Exhibit 2, you will see the effect of negative accrued interest. On each ex-coupon date, the accrued interest drops to a very slightly negative value before gradually rising again.
Clean prices may not be quoted if there is uncertainty as to whether coupons will be paid on schedule. If a bond is in default, an all inclusive invoice price is quoted, which can be presumed to reflect the market's assessment of the likelihood that future coupons will actually be paid as scheduled. Such bonds are said to trade flat. Income bonds trade flat. Because they pay no coupons, so do zero-coupon bonds.