أُحِلَّ لَكُمْ لَيْلَةَ الصِّيَامِ الرَّفَثُ إِلَى نِسَآئِكُمْ هُنَّ لِبَاسٌ لَّكُمْ وَأَنتُمْ لِبَاسٌ لَّهُنَّ عَلِمَ اللّهُ أَنَّكُمْ كُنتُمْ تَخْتانُونَ أَنفُسَكُمْ فَتَابَ عَلَيْكُمْ وَعَفَا عَنكُمْ فَالآنَ بَاشِرُوهُنَّ وَابْتَغُواْ مَا كَتَبَ اللّهُ لَكُمْ وَكُلُواْ وَاشْرَبُواْ حَتَّى يَتَبَيَّنَ لَكُمُ الْخَيْطُ الأَبْيَضُ مِنَ الْخَيْطِ الأَسْوَدِ مِنَ الْفَجْرِ ثُمَّ أَتِمُّواْ الصِّيَامَ إِلَى الَّليْلِ وَلاَ تُبَاشِرُوهُنَّ وَأَنتُمْ عَاكِفُونَ فِي الْمَسَاجِدِ تِلْكَ حُدُودُ اللّهِ فَلاَ تَقْرَبُوهَا كَذَلِكَ يُبَيِّنُ اللّهُ آيَاتِهِ لِلنَّاسِ لَعَلَّهُمْ يَتَّقُونَ
It has been made permissible for you the night preceding fasting to go to your wives [for sexual relations]. They are clothing for you and you are clothing for them. Allah knows that you used to deceive yourselves, so He accepted your repentance and forgave you. So now, have relations with them and seek that which Allah has decreed for you. And eat and drink until the white thread of dawn becomes distinct to you from the black thread [of night]. Then complete the fast until the sunset. And do not have relations with them as long as you are staying for worship in the mosques. These are the limits [set by] Allah , so do not approach them. Thus does Allah make clear His ordinances to the people that they may become righteous.
Bakara 187 (2/187)
The things that are not allowed in fast, are not allowed only during the time between dawn and sunset. "Becoming janabah" ruins your fast, but "being janabah" does not. "Being janabah" is a hindrance for salat, not for fast. "Being janabah" is an after-state of "becoming janabah". If the event of "becoming jahabah" was before the starting time of the fast, it won't affect your fast. It is like, "being full" is the after-state of "eating food"; "being full" does not ruin your fast, but "eating food" ruins.