ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:connection:day

day

From Version 5.21.0-beta-2

See Also

month()
year()

Syntax
string day(
    string $fieldName,
)

Description

The method day() is a helper routine that simplifies the creation of an oft-used SQL statement to obtain just the day of a specified date/time field as a 2 digit number (DD). If the value of the day is less than 10, it is zero padded. This allows for correct sorting.

Parameters

$fieldName

The date/time fieldname to be processed


Usage

In the following example, we analyze the most often occurring day of the month for a birth date

$sql = "SELECT {$db->day('birth_date')},COUNT(employees.*)
          FROM employees
          GROUP BY {$db->day('birth_date')}
          ORDER BY {$db->day('birth_date')} DESC";
$data = $db->getRow($sql); 
 
/*
* Returns 9 employees have their birth date on the 5th
* day of the month
*/
 
array(0=>array(0=>05,
               1=>9))
 
*/
v5/reference/connection/day.txt · Last modified: 2016/04/11 00:18 by mnewnham