Use Ohm's law. First you have to know the voltage drop accross the LED when lit to its desired level. For typical green LEDs, that's usually about 2.1 V. Red LEDs are lower, and IR LEDs even lower still. Blue and white are higher, like a bit over 3 V.
Let's say for sake of example you have a typical 20 mA green LED that drops 2.1 V. The battery puts out 9 V, so that leaves 9V - 2.1V = 6.9V accross the resistor in series with the LED. These LEDs can take 20 mA of current, but unless you expect to use it in a bright environment that will be overkill. Let's aim for about 10 mA LED current. Since the LED and resistor are in series, the LED current and the resistor current will be the same.
The question now is, what resistance drops 6.9 V at 10 mA? This is what Ohm's law is about. 6.9V / 10mA = 690Ω. The standard value of 680 Ω will be fine.
To calculate the run time, look at the battery Amp-hours spec. 9 V batteries have poor energy density for their size, and they are not a good choice for running a LED efficiently. I rarely use them so I don't remember what the capacity is, so I'll use 1 A-h for example only (could be quite off from a real 9 V battery.
The A-h capacity is in theory the current you can draw for 1 hour from a fresh battery until it is dead. You are drawing 10 mA, which is 1/100 Amps, so in theory a 1 A-h battery will last 100 hours. In practise less, as low as half that in cold for example.