Can anyone tell me please whether this sentence
Ich habe den ganzen Tag verbracht Deutsch zu lernen
is correct or not, if it's not correct can you tell me the right structure with same meaning
You are very close. You are just missing one word:
Ich habe den ganzen Tag damit verbracht, Deutsch zu lernen.
The structure is "etwas mit etwas verbringen". Since you use an erweiterter Infinitiv mit zu for the prepositional phrase "mit etwas", you need to insert the Verweiswort (Präpositionalpronom) "damit" because a preposition cannot just be omitted. If the erweiterter Infinitiv mit zu refers to such a Verweiswort, the comma is mandatory.
Other such Verweisworte are danach, darüber, davon, dafür, daran, dadurch ... They all are build by putting da(r)- in front of the preposition.