v5:reference:connection:day
This is an old revision of the document!
month
Description
The method month()
is a helper routine that simplifies the creation of an oft-used SQL statement to obtain just the month of a specified date/time field as a 2 digit number (MM). If the value of the month 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 are analyzing hire patterns by month of hire date
$sql = "SELECT {$db->month('hire_date')},COUNT(employees.*) FROM employees ORDER BY {$db->month('hire_date')}"; $data = $db->getAssoc($sql); /* * Returns array(01=>10, 02=>7, 03=>16, 06=>56, 07=>32, 08=>20, 09=>10, 10=>16, 12=>5) */
v5/reference/connection/day.1460326328.txt.gz · Last modified: 2017/04/21 11:35 (external edit)