_wp_mysql_week

Return a MySQL expression for selecting the week number based on the start_of_week option.

Description

(string) _wp_mysql_week( (string) $column ); 

Returns (string)

SQL clause.

Parameters (1)

0. $column (string)
Database column.

Usage

  1. if ( !function_exists( '_wp_mysql_week' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.php'; 
  3.  
  4. // Database column. 
  5. $column = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = _wp_mysql_week($column); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/functions.php  
  1. function _wp_mysql_week( $column ) { 
  2. switch ( $start_of_week = (int) get_option( 'start_of_week' ) ) { 
  3. case 1 : 
  4. return "WEEK( $column, 1 )"; 
  5. case 2 : 
  6. case 3 : 
  7. case 4 : 
  8. case 5 : 
  9. case 6 : 
  10. return "WEEK( DATE_SUB( $column, INTERVAL $start_of_week DAY ), 0 )"; 
  11. case 0 : 
  12. default : 
  13. return "WEEK( $column, 0 )";