Our hot water is hot sometimes, but not always. For example I might be able to fill up a tub with hot water one morning, but the next morning the water might be cold. This is our first home and when we bought it the water heater was already old. If we need a new one is it hard to install?
For starters, check for leaks. A hot water heater that can't consistently heat water is likely either a) leaking or b) has a faulty heating element.
Hot water heaters typically have a 10 year lifespan. There should be a date somewhere on the tank. If you're handy with electrical (or gas) and plumbing, it's not a big deal to swap out. If you're not, you'll want to bring in a plumber.
If you do want to bring in a plumber, then hire one BEFORE the heater springs a major leak. Emergency rates for a plumber are not fun. ;)
Note that all hot water heaters have something called a 'sacrificial anode' that you can replace regularly to extend the life of the tank. It's a rod of metal that will corrode saving the tank, itself. That said, very few replace them...even people like me, that know I should. ;) But it is a relatively cheap way to extend the life of the tank.
Hot water heaters generally last a LOOONG time if properly maintained. Mine is original to a 30-year-old house and still works great.
Intermittent hot water is usually one of two things; a faulty heating element, or slow overall heating coupled with demand elsewhere. If your wife or kids took a shower before you ran your bath, they may have drained the tank of hot water leaving none for you. A faulty heating element could heat one day and then not the next; more often it will work and not work in fits and starts throughout the day.
The first thing to try is flushing the tank. Over time, sediment can build up on the bottom of the tank and reduce the effectiveness of the primary (lower) heating element. Most HWHs have a purge valve at the bottom for exactly this purpose; hook up a standard garden hose and run it outside, then open the purge valve and let the water flow for a minute, maybe two. You should do this once every year or two; it's part of basic HWH maintenance.
The next thing to try is replacing the heating elements. This will require shutting off the water to the whole house (unless you have shutoffs to the tank itself) and draining the tank, then cutting the tank's breaker. Install the new element (you'll need to know either the model of your HWH or the part number for the specific element you're replacing when shopping) and turn everything back on.
If you have to replace the HWH it's usually not a monumental job (depending on the location of the heater in your home; the plumbing connections are usually readily accessible, and worst-case (when the lines aren't "flexible" piping and the connections on the new heater don't match the old) you'll only have to disassemble said plumbing back to where the connections come out of the wall. However, you will have to shut off the water to the entire house, and you may have to drain the lines if your home is two-story or the HWH is in the basement, which can require a few buckets or bus tubs. Then you disconnect the old HWH from power and water connections (it's usually helpful to mark where everything went on the old heater so you know what's what), drain and remove the old heater, put the new heater in place, and reconnect, using teflon tape to seal threaded connections. You'll need to make sure when shopping that the new HWH doesn't have power requirements exceeding the existing circuit; 9 times out of 10 the HWH is one of the larger dual-pole breakers and should be easy to find. Take the amperage rating, printed on either of the ganged switches on the dual-pole breaker (for instance 30), multiply that by 220 (6,600), then multiply by .8 (5,280). The wattage requirement of your new HWH should not exceed this number.
Overall, it's on the upper edge of the average homeowner's capabilities; not as difficult (or engineering-dependent) as knocking out a wall, more difficult than hooking up a washer/dryer, somewhere approaching replacing a faucet and sink.
If you don't think you can handle it or don't want to deal, a lot of your larger appliance stores (Lowe's, Sears, HD) have installation services on major appliances such as HWHs. Lowe's doesn't say specifically what it'd cost you, but they'll install an entire home's worth of blinds for $120, and to my way of thinking that'd require more man-hours than hooking up a HWH. Ask before you buy; it may be free, it may be $200.
This is long solved I hope, almost a year later, but for people searching Google, I had the same problem once and it was the thermostat (that read the water temperature and turned on the element) that was shot. It took the technician maybe 20 minutes to replace it.