Added JDatabaseQuery function to extract part of timestamp. #758
Conversation
database independent manner. Added MySQL test of element string conversion.
Unit testing complete. There were 1 failures and 0 errors from 1944 tests and 11088 assertions. |
Build triggered by changes to the head. Unit testing complete. There were 0 failures and 0 errors from 1944 tests and 11091 assertions. |
Would it be simpler to add these functions (and thus restrict the 'part' value)
? Allowing to precise the 'part', developers could use some mysql functions that could not exist in other db engines |
Yes it could be simpler. Ing. Gabriele Pongelli |
"month", "day", "hour", "minute", "second" .
Are there differences in the way different databases handle the date parts? |
Yes, an example extracting year from a date between MySQL and PostgreSQL . Mysql: YEAR(dateColumn) Eng. Gabriele Pongelli |
Ok, in that case I agree with Christophe. I think it would be better to add the extra methods. |
I did the changes locally but I haven't pushed them yet, I'll do soon. Eng. Gabriele Pongelli. |
Pushed last commits. Eng. Gabriele Pongelli. |
Build triggered by changes to the head. Unit testing complete. There were 0 failures and 0 errors from 1991 tests and 11149 assertions. |
Added JDatabaseQuery function to extract part of timestamp.
Nice job. Merged. |
This function is used to extract part of date from timestamp in a database independent manner.
Added MySQL test of element string conversion.
Usage:
$query->day($query->quoteName('dateColumn'))
for MySQL will return "DAY( dateColumn )"
$query->month($query->quoteName('dateColumn'))
for MySQL will return "MONTH( dateColumn )"
$query->year($query->quoteName('dateColumn'))
for MySQL will return "YEAR( dateColumn )"
$query->hour($query->quoteName('dateColumn'))
for MySQL will return "HOUR( dateColumn )"
$query->minute($query->quoteName('dateColumn'))
for MySQL will return "MINUTE( dateColumn )"
$query->second($query->quoteName('dateColumn'))
for MySQL will return "SECOND( dateColumn )"