Skip to content

Instantly share code, notes, and snippets.

@makoru-hikage
Last active March 2, 2017 10:21
Show Gist options
  • Save makoru-hikage/9904c66d6749791e3a3301672f89de46 to your computer and use it in GitHub Desktop.
Save makoru-hikage/9904c66d6749791e3a3301672f89de46 to your computer and use it in GitHub Desktop.
A query that determines the 1st part (regardless of division type) of an academic year by means of starting and ending date.
SET @yds = 2016;
SET @yde = 2016;
SET @type = 'Semester';
SELECT
*
FROM
school_calendar
WHERE
part_number = 1
AND division_type = @type
AND YEAR(date_start) BETWEEN (@yds - 1) AND @yds
AND YEAR(date_end) BETWEEN @yde AND (@yde + 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment