ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:connection:month

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

v5:reference:connection:month [2016/04/11 00:21] (current)
mnewnham created
Line 1: Line 1:
 +====== month ======
 +~~NOTOC~~
 +<WRAP right box>
 +**From Version 5.21.0-beta-2**
 +== See Also ==
 +[[v5:​reference:​connection:​day|day()]]\\
 +[[v5:​reference:​connection:​year|year()]]\\
 +== Syntax ==
 +  string day(
 +      string $fieldName,
 +  )
 +</​WRAP>​
 +===== 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
 +<code php>
 +
 +$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))
 +
 +*/
 +</​code>​
v5/reference/connection/month.txt ยท Last modified: 2016/04/11 00:21 by mnewnham