====== month ======
~~NOTOC~~
**From Version 5.21.0-beta-2**
== See Also ==
[[v5:reference:connection:day|day()]]\\
[[v5:reference:connection:year|year()]]\\
== Syntax ==
string month(
string $fieldName,
)
===== 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 analyze the most often occurring
month of the year for a birth date
$sql = "SELECT {$db->month('birth_date')},COUNT(employees.*)
FROM employees
GROUP BY {$db->month('birth_date')}
ORDER BY {$db->month('birth_date')} DESC";
$data = $db->getRow($sql);
/*
* Returns 14 employees have their birth date on the 8th
* month of the year
*/
array(0=>array(0=>08,
1=>14))
*/