_wp_mysql_week

The timeline below displays how wordpress function _wp_mysql_week has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Returns a MySQL expression for selecting the week number based on the start_of_week option.
 *
 * @ignore
 * @since 3.0.0
 *
 * @param string $column Database column.
 * @return string SQL clause.
 */
function _wp_mysql_week($column)
{
    $start_of_week = (int) get_option('start_of_week');
    switch ($start_of_week) {
        case 1:
            return "WEEK( {$column}, 1 )";
        case 2:
        case 3:
        case 4:
        case 5:
        case 6:
            return "WEEK( DATE_SUB( {$column}, INTERVAL {$start_of_week} DAY ), 0 )";
        case 0:
        default:
            return "WEEK( {$column}, 0 )";
    }
}

WordPress Version: 5.3

/**
 * Return a MySQL expression for selecting the week number based on the start_of_week option.
 *
 * @ignore
 * @since 3.0.0
 *
 * @param string $column Database column.
 * @return string SQL clause.
 */
function _wp_mysql_week($column)
{
    $start_of_week = (int) get_option('start_of_week');
    switch ($start_of_week) {
        case 1:
            return "WEEK( {$column}, 1 )";
        case 2:
        case 3:
        case 4:
        case 5:
        case 6:
            return "WEEK( DATE_SUB( {$column}, INTERVAL {$start_of_week} DAY ), 0 )";
        case 0:
        default:
            return "WEEK( {$column}, 0 )";
    }
}

WordPress Version: 4.2

/**
 * Return a MySQL expression for selecting the week number based on the start_of_week option.
 *
 * @ignore
 * @since 3.0.0
 *
 * @param string $column Database column.
 * @return string SQL clause.
 */
function _wp_mysql_week($column)
{
    switch ($start_of_week = (int) get_option('start_of_week')) {
        case 1:
            return "WEEK( {$column}, 1 )";
        case 2:
        case 3:
        case 4:
        case 5:
        case 6:
            return "WEEK( DATE_SUB( {$column}, INTERVAL {$start_of_week} DAY ), 0 )";
        case 0:
        default:
            return "WEEK( {$column}, 0 )";
    }
}

WordPress Version: 4.0

/**
 * Return a MySQL expression for selecting the week number based on the start_of_week option.
 *
 * @internal
 * @since 3.0.0
 *
 * @param string $column Database column.
 * @return string SQL clause.
 */
function _wp_mysql_week($column)
{
    switch ($start_of_week = (int) get_option('start_of_week')) {
        case 1:
            return "WEEK( {$column}, 1 )";
        case 2:
        case 3:
        case 4:
        case 5:
        case 6:
            return "WEEK( DATE_SUB( {$column}, INTERVAL {$start_of_week} DAY ), 0 )";
        case 0:
        default:
            return "WEEK( {$column}, 0 )";
    }
}

WordPress Version: 3.7

/**
 * Returns a MySQL expression for selecting the week number based on the start_of_week option.
 *
 * @internal
 * @since 3.0.0
 * @param string $column
 * @return string
 */
function _wp_mysql_week($column)
{
    switch ($start_of_week = (int) get_option('start_of_week')) {
        default:
        case 0:
            return "WEEK( {$column}, 0 )";
        case 1:
            return "WEEK( {$column}, 1 )";
        case 2:
        case 3:
        case 4:
        case 5:
        case 6:
            return "WEEK( DATE_SUB( {$column}, INTERVAL {$start_of_week} DAY ), 0 )";
    }
}