All perfect praise be to Allaah, the Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His Slave and Messenger.
If it crossed your mind on the eve of the second day that the next day was Ramadan and you would fast it, then the intention would be harbored and your fasting would be valid. However; if you did not remember that nor did you determine to observe fasting on it, your fasting would be invalid even if you had harbored the intention on the eve of the first day. This is because a fasting day’s eve is the only valid time for harboring the intention of fasting. Therefore, your intention before the eve of the day of fasting is worthless. In Al-Mughni, Ibn Qudaamah said, "To sum up, fasting - obligatory or voluntary - will not be valid except with an intention according to the consensus of scholars. If the fasting is obligatory, as in Ramadan, then our Imaam, Maalik and Ash-Shaafi‘i maintain that the intention of fasting must be harbored at night (i.e. the eve of the day to be fasted on)."
In Al-Mawsoo‘ah Al-Fiqhiyyah, it is written on the conditions of validity of fasting,
Third: Harboring intention at night. This is a condition to make the obligatory fasting valid according to the Maaliki, Shaafi‘i, and Hanbali scholars. The time of harboring the intention extends from sunset till the break of dawn. It is permissible to harbor it at the first part of the night, but it is not valid before that.
Allaah Knows best.