when is a y a vowel?
Always. And never
English is a weido language. Very loosey-goosey. That is so because about 500 years ago English orthography was messed up by a bunch of immigrant Dutch typesetters and printers who, having spoken Flemish all their lives, had a REALLY hard time deciding what the SOUNDS of English are. So what they couldn't hear right, they just dealt with as the mood struck them. They were lazy to boot, and short of type, so they were always trying to make one letter from the type font do the work of two. We are stilling coping with the consequences.
The "y" in the word "my" is one of of the problems those boys bequethed us. Any sensible person hearing the word "my" spoken by an Englishman would spell it "mai". That "ai" combo is a special kind of vowel technically called "diphthong" and English is rife with diphthongs. So those old typesetter types saved a whole lot of labour by using the single letter "y" to represent the "ai" sound. So you see, "y" is really a vowel.
But now consider the word "beyond" and one of its archaic relatives, viz the word 'yonder", meaning "over there". The first sound you make when you say "yonder", and the first sound in the second syllable of be-yond, is phonemically considered a consonant. But our lazy frinds decided that that sound, which is totally incomprensible to the Flemish ear, didn't warrant a letter of it's own to represent it, and the letter "y", of which there was always a surplus in the font, would do for that sound as well as the "ai" sound! And that accounts for the fact than when you see the exclamation "The Gods!" rendered jocularly, it is spelled "Ye Gods!". So you see, "y" is really a consonant!
But don't let it worry you. Just be glad that English has become the lingua franca throughout the world just because it IS so loosey-goosey and irrational that anybody can learn to speak it well enough to be understood in no time flat