When is Y a Vowel?

A, E, I, O, U and sometimes Y is a saying that is taught in elementary school when learning the vowels. Y is a vowel when the word doesn’t contain an A, E, I, O or U like in the word sky.