[TYPO3-mvc] How to add a SQL function in a query

Rayuth You rayuth at web-essentials.asia
Fri Sep 16 13:50:29 CEST 2011


Hi Bastian

Good, I nearly forgot about year. the year is duration.
I wish it works :)

Thanks,
Rayuth

On 09/16/2011 04:20 PM, Bastian Waidelich wrote:
> Rayuth You wrote:
>
> Hi Rayuth,
>
>>> $query->equals('YEAR(crdate)','2011')),
>
> Nice idea, but that will only return records with the crdate (timestamp)
> being equal to exactly 1293861600.
>
> Instead you could find out the start- end end timestamp of the given
> year, eg with:
>
> $year = 2011;
> $startTimestamp = mktime(0, 0, 0, 1, 1, $year);
> $endTimestamp = mktime(23, 59, 59, 12, 31, $year);
>
> $query->matching(
> $query->logicalAnd(
> $query->greaterThanOrEqual('crdate', $startTimestamp),
> $query->lessThanOrEqual('crdate', $endTimestamp),
> $query->equals('name','blabla')
> )
> )->execute();
>
> (untested)
>
> HTH,
> Bastian



More information about the TYPO3-project-typo3v4mvc mailing list