There are three ways that we can understand the idea of a day…
The first is a 24 hour day. Technically, the sun has nothing to do with a 24 hour day. The 24 hour day has everything to do with how long it takes for the earth to rotate once. Right now at the North Pole they won’t see the sun for another month or so, but it still takes the globe 24 hours to spin all the way around. Many people believe that the earth was created in six 24 hour days. And this view can easily be understood if for no other reason then the author 6 times says “there was evening and there was morning”. This however may simply be a way of expressing the transition from one stage of creation to another.
The second definition of day has to do with the time when there is light outside. Likewise, the time when it is dark outside is called night even though night is a part of the same 24 hour day. The first order of God’s creation was to make light and separate it from the darkness. God distinctly calls the light “day” even though there is no mention of sun for another couple ‘days.’ So in one verse God the author of Genesis used two definitions of the word day: the definition of day that associates with light, and the definition of day that associates with time. But when it comes to time, 24 hours is not the only time-related definition of day.
The third kind of day is also related to time, not lightness. It is a long period of time, an age of time, or longer. For example our grandparents may have said of their youth, “back in my day” in which case “day” may represent several years of their lives. Sometimes we might say the day (or age) of the dinosaurs is over. In those cases a day is not a specific length of time, but a very long time with imprecise boundaries. It is very likely that this might be the proper understanding of day in Genesis 1, as God may have taken years or epochs to create things. (see the post on evolutionism vs. creationism).
In short, the sun is only a small part of the meanings concerning the word day. Thus, there could have been days before the third ‘day’ of creation.