Hi Dave,
Yes 'field' have date attributes. This is the way, we have defined field in 
the model:

db.define_table('tablename',
    Field('field1', 'integer', writable=False, label=T('Field1')),
    Field('field2', 'string', label=T('Field2')),
    Field('field3', 'date', label=T('Field3')),
    )


On Tuesday, June 30, 2015 at 12:22:57 AM UTC+5:30, Dave S wrote:
>
>
>
> On Monday, June 29, 2015 at 12:19:21 AM UTC-7, MS wrote:
>>
>>
>>  
>>
>> We have a Web2py application hosted on Google app engine.
>>
>> We are trying to implement Taskqueue for fetching record from tables, we 
>> are passing the filter field (date type) and number of years as parameters. 
>> These parameters will be then passed to a Query to fetch the data from the 
>> Database.
>>
>> Please find the code snippet as given below:
>>
>> Task_handler() function accepts the 2 input parameters and calls the 
>> taskqueue which is defined in the task_process() function. In 
>> task_process() function we are calculating the date based on the number of 
>> years parameters and using it in the query to fetch the records older than 
>> the calculated date.
>>
>> def task_handler():
>>
>>       if len(request.args):
>>
>>                 field= request.args[0]
>>
>> filter=int(request.args[1])
>>
>>        return 
>> taskqueue.add(url=URL('task_process'),params={’field’:field,'diff': 
>> filter,},method="POST")
>>
>>        
>>
>> def task_process():
>>
>>                 field= request.form.get(‘field’)
>>
>> diff = request.form.get('diff')
>>
>>     filter_date = datetime.date.today() + 
>> datetime.timedelta(-(365*(diff)))
>>
>>     result = [] 
>>
>>     result = db(field < filter_date).select()
>>
>>  
>>
>> Note :
>> field in this case is db.<tablename>.<columnname>
>>
>>  
>>
>> If we directly use the input parameter in query, it fails due to datatype 
>> mismatch.
>>
>> So we tried by hard-coding the table field name in the query but got 
>> Attribute Error for that.
>>
>
>  Perhaps you could show how you define "field" in your model.  Does 
> "field" have datetime attributes?  It looks to me like your select expects 
> it to.
>
> /dps
>
>  
>>
>> Kindly provide your inputs on what are we missing here or doing wrong.
>>
>>  
>>
>> Thanks.
>>
>

-- 
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