Re: [web2py] Re: Adding date() and time() to Field object

2011-07-21 Thread Angelo Compagnucci
Thanks Massimo! 2011/7/21 Massimo Di Pierro massimo.dipie...@gmail.com: it  would be much easier to just provide a function row.field.asdate() or row.field.astime() How this could be done? Give me an hint and I'll procede by myself! Thank you!

Re: [web2py] Re: Adding date() and time() to Field object

2011-07-21 Thread Vasile Ermicioi
I think row.field.date() already works because row.field is a datetime object

[web2py] Re: Adding date() and time() to Field object

2011-07-21 Thread Massimo Di Pierro
True. I just checked and this already works . :-) On Jul 21, 4:36 am, Vasile Ermicioi elff...@gmail.com wrote: I think row.field.date()  already works because row.field is a datetime object

Re: [web2py] Re: Adding date() and time() to Field object

2011-07-21 Thread Angelo Compagnucci
Sorry for being retarted! I have this: db.define_table('test', Field('comment','string'), Field('data','datetime')) but the function: def getcommentsbydate(): rows = db(db.test).select(db.test.data.comment, db.test.data.date()) return dict(rows=rows) throws an exception complaining that

[web2py] Re: Adding date() and time() to Field object

2011-07-21 Thread Massimo Di Pierro
No that does not work for the reasons discussed above but this does def getcommentsbydate():    rows = db(db.test).select(db.test.data.comment, db.test.data) for row in rows: row.data = row.data.date()    return dict(rows=rows) On Jul 21, 8:06 am, Angelo Compagnucci

Re: [web2py] Re: Adding date() and time() to Field object

2011-07-21 Thread Angelo Compagnucci
Thanks Massimo! So I must traverse the list at least one time. I dont know how much time is spent in this operation, but I have a very large number of records, so I'll test this solution. Thank you! 2011/7/21 Massimo Di Pierro massimo.dipie...@gmail.com: No that does not work for the reasons

Re: [web2py] Re: Adding date() and time() to Field object

2011-07-21 Thread pbreit
I don't know exactly how virtual fields are implemented (if it would prevent another run through the result set) but might be another approach. http://web2py.com/book/default/chapter/06#Virtual-Fields

[web2py] Re: Adding date() and time() to Field object

2011-07-21 Thread Massimo Di Pierro
You can just call row.data.date() instead of row.data when you need the value. On Jul 21, 10:49 am, Angelo Compagnucci angelo.compagnu...@gmail.com wrote: Thanks Massimo! So I must traverse the list at least one time. I dont know how much time is spent in this operation, but I have a very

Re: [web2py] Re: Adding date() and time() to Field object

2011-07-21 Thread Angelo Compagnucci
I'll try to explain better. I have to exctract some statistics from a radius accounting table that is generally a really big table. After exctracting tha data, i pass it to jqplot.com via a json service to be rendered. For some graphics, I have to exctract a big amount of dates from accounting

[web2py] Re: Adding date() and time() to Field object

2011-07-20 Thread Massimo Di Pierro
I agree it would be useful. It will be tricky to implement. Moreover row = db().select(db.table.field.date()).first() would not go into row.field but into row[db.table.field.date()] it would be much easier to just provide a function row.field.asdate() or row.field.astime() On Jul 20, 5:03