According to the 1981 Second Edition of the Guinness Book Of Music
, "Himno Da Carta" is the only national anthem ever to have been written by a ruling monarch. The Portuguese National Anthem from 1826-1910 was composed by Pedro I of Brazil in 1822 to commemorate his country's independence; he is said to have begun writing it at 5.30 in the morning, on September 7, 1822, and to have finished it by 9 pm. the same night. And then to have sung it in Sao Paulo with a full chorus the same night.
As national anthems go, it is a fair effort although the music is definitely superior to the words; the title, which can be translated as "Anthem Of The Charter," alludes to the charter he gave the Portuguese. Pedro I of Brazil was also Pedro IV of Portugal.
On the day he wrote it - obviously pleased with his work - he declared it would be the National Anthem of Brazil. In 1826, he succeeded his father John VI as King of Portugal, and took the "Himno Da Carta" with him leaving Brazil without a national anthem!
As well as the only national anthem composed by a serving monarch, the "Himno Da Carta" is also almost certainly the one composed in the shortest time.
Alexander Baron - London, England