If i code

db.define_table('test11',
    Field('nome'),
    Field('datt','datetime'))
db.test11.datt.requires=[IS_DATE(format=T('%Y/%m/%d %H:%M:%S'),
error_message=T("Formato pretendido aaaa/mm/dd"))]

It saves the record with 2012/01/01 00:00:00 in the datt field clearing my
time selection in the form and zeroing minutes seconds and hours

But if i remove the line
*db.test11.datt.requires=[IS_DATE(format=T('%Y/%m/%d %H:%M:%S'),
error_message=T("Formato pretendido aaaa/mm/dd"))]*
It saves the record as 01-01-2012 18:08:22
It saves the time as i selected (18:08:22)

What do i do? i need the datetime as %Y/%m/%d %H:%M:%S but forcing it with
requires clears my time value


2013/9/11 António Ramos <ramstei...@gmail.com>

> sorry the copy paste
>
> i have this output
> In [18]: IS_DATE(format=T('%Y/%m/%d %H:%M:%S'),error_message=T("Formato
> pretendido aaaa/mm/dd HH:MM:SS"))("2013/09-25 09:54:24")
> Out[18]: ('2013/09-25 09:54:24', 'Formato pretendido aaaa/mm/dd HH:MM:SS')
>
> and this
>
>
> In [8] : IS_DATE(format=T('%Y/%m/%d %H:%M:%S'),error_message=T("Formato
> pretendido aaaa/mm/dd HH:MM:SS"))("2013/09/25 09:54:24")
> (datetime.date(2013, 9, 25), None)
>
>
>
> 2013/9/11 Federico Ferraro <fferrar...@gmail.com>
>
>> Test  it and validator not error :
>>
>> IS_DATE(format=T('%Y/%m/%d %H:%M:%S'),error_message=T("Formato pretendido
>> aaaa/mm/dd HH:MM:SS"))("2013/09/25 09:54:24")
>> Out[17]: (datetime.date(2013, 9, 25), None)
>>
>>
>> In [18]: IS_DATE(format=T('%Y/%m/%d %H:%M:%S'),error_message=T("Formato
>> pretendido aaaa/mm/dd HH:MM:SS"))("2013/09-25 09:54:24")
>> Out[18]: ('2013/09-25 09:54:24', 'Formato pretendido aaaa/mm/dd HH:MM:SS')
>>
>>
>>
>>
>> 2013/9/11 António Ramos <ramstei...@gmail.com>
>>
>>> The field was only date and i changed it to datetime afer realised i
>>> needed the time
>>>
>>>
>>>
>>> 2013/9/11 Niphlod <niph...@gmail.com>
>>>
>>>> data will always be stored in ISO format. SQLite in addition stores
>>>> datetimes as strings 'cause there's no datetime native field.
>>>> Did you change the field after creating it ? Does this error happen
>>>> also on a clean database ?
>>>>
>>>>
>>>> On Wednesday, September 11, 2013 10:58:56 AM UTC+2, Ramos wrote:
>>>>>
>>>>> my db.py
>>>>> db.define_table('oco',
>>>>>  Field('created_on', 'datetime', required=True,label='Data'),
>>>>> ...
>>>>> ...
>>>>>
>>>>> db.oco.created_on.requires=[**IS_DATE(format=T('%Y/%m/%d %H:%M:%S'),
>>>>> error_message=T("Formato pretendido aaaa/mm/dd HH:MM:SS"))]
>>>>>
>>>>>
>>>>> I create a record with created_on set to
>>>>>
>>>>> 2013/09/25 09:54:24
>>>>>
>>>>> I get this error
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> 1.
>>>>> 2.
>>>>> 3.
>>>>> 4.
>>>>> 5.
>>>>> 6.
>>>>> 7.
>>>>> 8.
>>>>> 9.
>>>>> 10.
>>>>> 11.
>>>>> 12.
>>>>> 13.
>>>>> 14.
>>>>> 15.
>>>>> 16.
>>>>> 17.
>>>>> 18.
>>>>> 19.
>>>>> 20.
>>>>> 21.
>>>>> 22.
>>>>> 23.
>>>>> 24.
>>>>>
>>>>> Traceback (most recent call last):
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>   File "C:\web2py2\gluon\restricted.**py", line 209, in restricted
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>     exec ccode in environment
>>>>>   File "C:/web2py2/applications/**empre/controllers/default.py" 
>>>>> <https://apps.cires.pt/admin/default/edit/empre/controllers/default.py>, 
>>>>> line 1120, in <module>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>   File "C:\web2py2\gluon\globals.py", line 186, in <lambda>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>     self._caller = lambda f: f()
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>   File "C:/web2py2/applications/**empre/controllers/default.py" 
>>>>> <https://apps.cires.pt/admin/default/edit/empre/controllers/default.py>, 
>>>>> line 486, in index
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>     for oco in db(db.oco.rel_trab.contains(tr**ab.id)).select():
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>   File "C:\web2py2\gluon\dal.py", line 8766, in select
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>     return adapter.select(self.query,fiel**ds,attributes)
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>   File "C:\web2py2\gluon\dal.py", line 2094, in select
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>     return super(SQLiteAdapter, self).select(query, fields, attributes)
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>   File "C:\web2py2\gluon\dal.py", line 1594, in select
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>     return self._select_aux(sql,fields,at**tributes)
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>   File "C:\web2py2\gluon\dal.py", line 1559, in _select_aux
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>     self.execute(sql)
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>   File "C:\web2py2\gluon\dal.py", line 1671, in execute
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>     return self.log_execute(*a, **b)
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>   File "C:\web2py2\gluon\dal.py", line 1665, in log_execute
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>     ret = self.cursor.execute(*a, **b)
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>   File "c:\Python27\lib\sqlite3\**dbapi2.py", line 63, in convert_date
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>     return datetime.date(*map(int, val.split("-")))
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ValueError: invalid literal for int() with base 10: '25 00:00:00'
>>>>>
>>>>> I see that in my sqlite file the date was set to 2013-09-25 00:00:00
>>>>> instead of 2013/09/25 09:54:54
>>>>>
>>>>> What i wrong?
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>  --
>>>> 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/groups/opt_out.
>>>>
>>>
>>>  --
>>> 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/groups/opt_out.
>>>
>>
>>
>>
>> --
>> --
>> Federico Ferraro
>> Usuario Linux : 482533.
>> --
>>
>> --
>> 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/groups/opt_out.
>>
>
>

-- 
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/groups/opt_out.

Reply via email to