This gives me the year and quarter from any date:
CONCAT(STRING(YEAR(mydate)),'-Q',STRING(QUARTER(mydate))) as quarter
Result: 2016-Q2, 2016-Q3, 2016-Q4, 2017-Q1, etc
What should I write to get the half year? (2017-S1, 2017-S2, etc)
S1 (Semester 1) is between Jan 1st-Jun 30th; S2 (Semester 2) is between Jul 1st-Dec 31st.
Had no problem making dates into quarters and then connecting other tables data to the right quarter, but don't know how to do half years (i know the direct formula does not exist in sql). Thanks!