private static List<Appointment> findMonthlyByDaySpan(long uid,
			long startDay, long endDay) throws SQLException {
		List<Appointment> aAppt = new ArrayList<Appointment>();
		PreparedStatement statement = null;
		// select * from Appointment where frequency = $MONTHLY
		// and startTime <= $(endDay + DateUtil.DAY_LENGTH)
		// and $startDay <= lastDay
		String str =
				"select * from (" + makeSqlSelectorForUser(uid)
						+ ") as Temp where frequency = ? "
						+ "and startTime <= ? " + "and ? <= lastDay ";

		Date startD = new Date(startDay);
		Date endD = new Date(endDay);
		if (startD.getMonth() == endD.getMonth())
		{
			// if within a month
			str += "and ? <= freqHelper and freqHelper <= ? ";
			statement = connect.prepareStatement(str);
			statement.setInt(4, Appointment.computeFreqHelper(
					Frequency.MONTHLY, startDay));
			statement.setInt(5, Appointment.computeFreqHelper(
					Frequency.MONTHLY, endDay));
		} else
		{
			// if span 2 months
			Date startOfMonth2D = new Date(endD.getYear(), endD.getMonth(), 0);
			long endOfMonth1 =
					new Date(startOfMonth2D.getTime() - DateUtil.DAY_LENGTH)
							.getTime();
			str +=
					"and (? <= freqHelper and freqHelper <= ? or freqHelper <= ?) ";
			statement = connect.prepareStatement(str);
			statement.setInt(4, Appointment.computeFreqHelper(
					Frequency.MONTHLY, startDay));
			statement.setInt(5, Appointment.computeFreqHelper(
					Frequency.MONTHLY, endOfMonth1));
			statement.setInt(6, Appointment.computeFreqHelper(
					Frequency.MONTHLY, endDay));

		}

		statement.setInt(1, Frequency.MONTHLY);
		statement.setLong(2, endDay + DateUtil.DAY_LENGTH);
		statement.setLong(3, startDay);

		ResultSet resultSet = statement.executeQuery();
		while (resultSet.next())
		{
			aAppt.add(Appointment.createOneFromResultSet(resultSet));
		}
		return aAppt;
	}