The last dose of the vaccine (second dose) must have been taken in the last 270 days for the vaccination certificate to be valid to enter Spain. The certificate does not expire after 270 days as long as its holder remains under 18 years old.