Asks how many years (duration). Used to inquire about the length of time in years (e.g., "How many years will it take?").
このプロジェクトは何年かかりますか?
How many years will this project take?
彼は会社に何年勤めていますか?
How many years has he worked at the company?
留学は何年の予定ですか?
How many years do you plan to study abroad?
Asks which year (calendar year). Used to ask for a specific year (e.g., "What year is it?").
あなたは何年の出身ですか?
What year were you born in? / Which year are you from?
その出来事は何年のことですか?
What year did that event occur?
新しい元号は何年から始まりますか?
From which year does the new era name begin?