Thanks a lot Anthony, it really helped! Anna On Sunday, 7 September 2014 03:34:42 UTC+2, Anthony wrote: > > For transformation for display in the grid, SQLTABLE, and read-only form > fields, you can use the "represent" attribute of the field: > > db.define_table('mytable', > Field('mytime', represent=lambda v, r: time.strftime('%Y-%m-%d > %H:%M:%S', time.localtime(v)))) > > If you want to make sure the transformation happens whenever you do a > database select, regardless of whether you are using the grid, etc., you > can instead use "filter_out" ( > http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#filter_in-and-filter_out). > > The difference is that with filter_out, the value in the Rows object itself > is transformed, so you have no access to the original value; whereas with > "represent", the original value is in the Rows object, and the > transformation is only done when rendering (e.g., in the grid). > > Anthony > > On Saturday, September 6, 2014 7:04:10 PM UTC-4, Anna Kostikova wrote: >> >> Dear list, >> >> I am making a query to a database where I have a column which stores >> time in unix epoch format (1347517370). Then I use this query in >> sqlgrid.form to present results to the user. However, I would like to >> convert the epoch format into normal time representation as below: >> >> time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(1347517370)) >> >> How can I apply such a function to a specific column in a query so >> then the visual result is nicer and user readable? >> >> Thanks, >> Anna >> >
-- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.