A day on the Moon lasts 29.5 of our Earth days. In other words, if you were standing on the surface of the Moon, it would take 29.5 days for the Sun to move entirely through the sky and return to its original position.
As you probably know, the Moon is tidally locked to the Earth. This means that it always points the same face towards the Earth. We’re always looking at the same side of the Moon. If you were standing on the Moon, you would always see the Earth in exactly the same position, while the stars and the Sun moved around in the sky. The Moon takes 27.3 days to complete an orbit around the Earth. And this the same amount of time that it takes to turn once on its axis.
Wait a second, which is it? 29.5 days or 27.3 days? Here’s the problem. As the Moon is orbiting the Earth, the Earth is orbiting the Sun. The Earth returns to its same position in orbit every 365 days. So in order for the Sun to catch up to its same position in the sky from the perspective of the Moon, it has to turn a little more. The extra 2.2 days is the time for the Moon to catch up in its rotation.
The amount of time the Moon takes to complete one turn on its axis with respect to the stars is 27.3 days, and it’s called a sidereal day.
The amount of time it takes for the Sun to return to the same position in the sky is called a synodic day, and that’s what takes 29.5 days.
You think that’s complicated, wait until you hear how long it takes for a day on the Earth.
You can listen to a very interesting podcast about the formation of the Moon from Astronomy Cast, Episode 17: Where Did the Moon Come From?