2017-06-27 11:01 GMT+02:00 Sergi Almacellas Abellana <se...@koolpi.com>:
> 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! > This is just that i need Thanks a lot > > -- > Sergi Almacellas Abellana > www.koolpi.com > Twitter: @pokoli_srk > > -- > You received this message because you are subscribed to the Google Groups > "tryton-dev" group. > To view this discussion on the web visit https://groups.google.com/d/ms > gid/tryton-dev/906ca9f7-71dc-deef-46ee-0210e427d137%40koolpi.com. > -- You received this message because you are subscribed to the Google Groups "tryton-dev" group. To view this discussion on the web visit https://groups.google.com/d/msgid/tryton-dev/CANd2Za3izns49XmA7FtRnwaFamZWK6w1%2BmFOv1DWpRF68n9mkw%40mail.gmail.com.