You can try and use this:

def is_date(string):
    try:
        parse(string)
        return True
    except ValueError:
        return False


if is_date(str(row['Created'])):
    request_created_date = datetime.datetime.strftime(row['Created'], "%Y-%m-%d 
%H:%M:%S")
else:
    request_created_date = datetime.datetime.now()



It worked for me.

Good luck
On Tuesday, May 26, 2009 at 4:19:10 PM UTC+2, ニコノコ wrote:
>
> Traceback (most recent call last): 
>   File "/home/ern/web2py/gluon/restricted.py", line 107, in restricted 
>     exec ccode in environment 
>   File "/home/ern/web2py/applications/smb/views/appadmin.html", line 
> 122, in <module> 
>   File "/home/ern/web2py/gluon/sqlhtml.py", line 623, in __init__ 
>     for (rc, record) in enumerate(sqlrows): 
>   File "/home/ern/web2py/gluon/sql.py", line 2196, in __iter__ 
>     yield self[i] 
>   File "/home/ern/web2py/gluon/sql.py", line 2151, in __getitem__ 
>     str(value)[:10].strip().split('-')] 
> ValueError: invalid literal for int() with base 10: '' 
>
> I was trying to go to database administration of db2 when I got this 
> error. The table is defined as follows: 
>
> db2.define_table('msg_log', 
>     SQLField('type', 'string'), 
>     SQLField('smsc', 'string'), 
>     SQLField('sent', 'datetime'), 
>     SQLField('received', 'datetime'), 
>     SQLField('sender', 'string'), 
>     SQLField('receiver', 'string'), 
>     SQLField('msgid', 'string'), migrate=False) 
>
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to