On Wednesday, February 12, 2014 5:11:29 PM UTC+2, Alex wrote: > > IS_DATETIME validator doesn't change anything. I doubt that validators are > used by the DAL. > I guess I have to use native sql to set milliseconds >
(Better late than never ... I just saw this) You don't have to go directly to native sql - you can supply a string (instead of a datetime object), in which case DAL does not change it and it will go to the database in the same format -- e.g. now = datetime.datetime.now() db(db.invoice.id<../url?q=http%3A%2F%2Fdb.invoice.id&sa=D&sntz=1&usg=AFQjCNETWqIpZvAYEHo7dENYLNi50gxHLA>== 743).update(invoice_date=now.isoformat()) (or stftime to a format your database understands) I have submitted a patch to fix this 3 years ago, which was rejected, but later Massimo added a "_before_udpate" / "_before_insert" hook which you can use to convert every time or datetime object to the proper string format. *Note*, however, that the reason my patch was rejected (and that web2py truncates to full seconds) is that not all databases and database backends support milliseconds in timestamps - and some silently truncate it at the database level. (I would prefer if web2py raised an exception rather than silently truncated - but since some backends have this behaviour, it is not completely unreasonable for web2py to have it as well). e.g. you may develop with sqlite (that does support it) and then move to Oracle which IIRC silently truncates, and be surprised it behaves differently - at least the way web2py behaves out of the box is consistent. -- 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.