El 26/06/17 a les 16:31, Nicolás López Solano ha escrit:
> Yes i tried. For postgresql it return a correct date but for sqlite it
> return only the year of the datetime base column.
>
> If i work directly executing sql (select cast(column as date) from
> mytable) over a sqlite file i get a similar "not good" result. Cast
> sqlite native functión can't covert to date.
Right, I can reproduce it on my local environemnt. In order to get a
proper date on sqlite you can use:
SELECT Date(column)
instead of
SELECT Cast(column as date)
So I ended up with the following code:
from sql.functions import Function
class SqlLiteDate(Function):
__slots__ = ()
_function = 'DATE'
if
backend.name() == 'sqlite':
date = SqliteDate(column)
else:
date = Cast(column, 'DATE')
Hope it helps!