ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:connection:year

This is an old revision of the document!


year

From Version 5.21.0-beta-2

See Also

day()
month()

Syntax
string year(
    string $fieldName,
)

Description

The method year() is a helper routine that simplifies the creation of an oft-used SQL statement to obtain just the year of a specified date/time field as a 4 digit number (YYYY).

Parameters

$fieldName

The date/time fieldname to be processed

Usage

/*
* To return an employee_no and the year of a date field,
* and sort by the hire date
 
*/
$sql = "SELECT emp_no, {$db->year('hire_date')} 
          FROM employees
          ORDER BY {$db->year('hire_date')}";
$data = $db->getAssoc($sql); 
v5/reference/connection/year.1460325349.txt.gz · Last modified: 2017/04/21 11:32 (external edit)