ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:connection:day

Differences

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

Link to this comparison view

v5:reference:connection:day [2016/04/11 00:12]
mnewnham created
v5:reference:connection:day [2016/04/11 00:18]
mnewnham
Line 1: Line 1:
-====== ​month ======+====== ​day ======
 ~~NOTOC~~ ~~NOTOC~~
 <WRAP right box> <WRAP right box>
 **From Version 5.21.0-beta-2** **From Version 5.21.0-beta-2**
 == See Also == == See Also ==
-[[v5:​reference:​connection:​day|day()]]\\+[[v5:​reference:​connection:​month|month()]]\\
 [[v5:​reference:​connection:​year|year()]]\\ [[v5:​reference:​connection:​year|year()]]\\
 == Syntax == == Syntax ==
-  string ​month(+  string ​day(
       string $fieldName,       string $fieldName,
   )   )
 </​WRAP>​ </​WRAP>​
 ===== Description ===== ===== 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. ​  +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 ===== ===== Parameters =====
 ==== $fieldName ==== ==== $fieldName ====
Line 19: Line 19:
 -------------------------------- --------------------------------
 ===== Usage ===== ===== Usage =====
-In the following example, we are analyzing hire patterns by month of hire date+In the following example, we analyze the most often occurring 
 +day of the month for a birth date
 <code php> <code php>
  
-$sql = "​SELECT {$db->month('hire_date'​)},​COUNT(employees.*)+$sql = "​SELECT {$db->day('birth_date'​)},​COUNT(employees.*)
           FROM employees           FROM employees
-          ORDER BY {$db->month('hire_date'​)}";​ +          ​GROUP BY {$db->​day('​birth_date'​)} 
-$data = $db->getAssoc($sql); ​+          ​ORDER BY {$db->day('birth_date'​)} ​DESC"; 
 +$data = $db->getRow($sql); ​
  
 /* /*
-* Returns+* Returns ​9 employees have their birth date on the 5th 
 +* day of the month 
 +*/ 
 + 
 +array(0=>​array(0=>​05,​ 
 +               ​1=>​9))
  
-array(01=>​10,​ 
-      02=>7, 
-      03=>16, 
-      06=>56, 
-      07=>32, 
-      08=>20, 
-      09=>10, 
-      10=>16, 
-      12=>5) 
 */ */
 </​code>​ </​code>​
- 
v5/reference/connection/day.txt · Last modified: 2016/04/11 00:18 by mnewnham