Deserts are hot mostly because of the lack of water. When the sun shines on the ground, all of the absorbed sunlight goes into raising the ground's temperature. If there was moisture in the soil, much of this heat would evaporate, pumping water vapour in the air, and keeping the soil cooler. This cooling is from the latent heat of evaporation that is required to change liquid water into water vapour. Associated with the lack of water is a lack of vegetation, which also evaporates water as part of photosynthesis. The vegetation itself doesn't cool the desert - it's the water being processed by the vegetation. In fact, since vegetation is darker than most desert soils, if a desert could have vegetation that didn't need water to live, the desert would actually be hotter since it would absorb more sunlight. Similarly, if deserts were covered by dark soil rather than light soil or sand, they would also be hotter. Therefore the common view that deserts are so hot because of the bright sand is incorrect.
Deserts are cold at night because of the lack of water in the ground, and little water vapour in the air, most deserts can get quite cool at night. This is because dry ground does not retain as much heat as moist ground. Also water vapour is the most important greenhouse gas, so dry air allows the surface to cool rapidly at night through loss of infrared radiation to outer space. In fact, it has been estimated that the Sahara Desert actually loses more infrared radiation than it gains solar radiation from the sun.