The hourly rate is specified in the retainer agreement. Some lawyers have one hourly rate for out-of-court work and another (and higher) rate for in-court appearances.
Lawyers bill for all work and graduate their billings in small fractions of an hour.