ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:connection:month
no way to compare when less than two revisions

Differences

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


Previous revision
v5:reference:connection:month [2022/08/22 12:50] (current) – [month] fix function name in syntax block dregad
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 month(
 +      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: 2022/08/22 12:50 by dregad