perhaps you can use count *e.g.* count_invoice = db.invoice.id.count() this_year = request.now.year this_month = request.now.month
query_invoice = ((db.invoice.invoice_date.year() == this_year) & (db.invoice.invoice_date.month() == this_month) ) query_count_invoice = db(query_invoice).select(count_invoice).first()[count_invoice] if db(query_invoice).select() else 0 invoice_no_count = int(query_count_invoice) + 1 if query_count_invoice else 1 invoice_no_format_count = format(invoice_no_count, '05') invoice_no = request.now.strftime('%y%m')+invoice_no_format_count best regards, stifan -- 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.