The sql_date_proche() function is used to return a conditional expression for a column in relation to a date.

It accepts 5 parameters:

  1. $champ is the SQL column to be compared,
  2. $interval is the comparison interval value: -3, 8, ...
  3. $unite is the units of reference (’DAY’, ’MONTH’, ’YEAR’, ...)
  4. $serveur,
  5. $option.

It is used as shown below:

$ifdate = sql_date_proche('column', -8, 'DAY');
$res = sql_select('column', 'table', $ifdate);


Another use for a selection query such as illustrated below, is to store the boolean result in an alias. The alias recently indicates whether or not an author has logged in during the last 15 days:

$row = sql_fetsel(
	array("*", sql_date_proche('en_ligne', -15, 'DAY') . " AS recently"), 
// $row['recently'] : true / false

Author Mark Baber Published : Updated : 12/03/23

Translations : English, français