It's a sprawling city, similar to that of Whiterun (capital of Whiterun Hold in Skyrim) with about 1500 inhabitants. Assume medieval-level technology and weapons, and also assume that the city is fairly sloped with a few natural hills scattered here and there.
The land there is still fertile, so about 400 farmers work the fields to provide food for the rest of the city, while there are about 200 merchants and traders who have small shops scattered around the city. Below the hills lie a valuable resource underground: precious ores and minerals. To exploit their natural resources, there are 100 miners in the city. The city is governed by a king, so there about 100 people who serve the king (servants and his cabinet). Another 300 residents are part of the city's army, tasked with defending the walls from foreign enemies, as the city is in the midst of a war with a neighboring settlement (with around the same population) that is located about 250 miles away. The remaining 400 are children.
Now to the question: Why would the people of this city always sleep during daylight hours (~7 AM to ~7 PM), while getting up and working during the nighttime (~7 PM to ~7 AM)? Anything I haven't stated explicitly stated in the question can be implied however you would like to support your answer.
I've only thought of two possible reasons: 1) their primary source of profit and sustenance is agriculture, and they mostly grow plants that grow more at night (like pumpkins), so eventually their culture evolved around this agriculture or 2) the temperature in the day is unbearably hot, so they need to work at night when cooler winds pass through.
Note: When I say the whole city sleeps during the daytime, I don't literally mean everyone, rather, I mean the vast majority of the residents. Those who aren't sleep will be inside of their own homes. Also, I'll be accepting an answer based on how many possible reasons the answer offers for this peculiar behavior. After all, this will be more convincing in my novel if there are several reasons, rather than just one, for this behavior to occur in the city.