I have a date field in this format: "17/01/2013" and I'm trying to use the ORM search function to find all records that match a certain year say 2012 for instance.
I've tried something like this but it didnt work:
my_obj.search(cr, uid, [('date', '>=', '01/01/' + h1.year), ('date', '<=', '31/12/' + h1.year)], order='date')
but it didn't work.
How can I achieve this with the ORM search function? More general, how can I construct a query to search for all records matching a specified year using a date field in the format shown above?
Hi. If you do not have any exact error message, just the result is NULL, may be your date format isn't good. You can check the system date format by print. Ex.
for obj in my_obj.browse(cr,uid,[some_id]): print obj.date
You can see the result, and you can modify your search condition according the result. Any others, please give more info's.
This is a date format.:
date_planned = datetime.strptime(order.shipping_date, DEFAULT_SERVER_DATE_FORMAT)
please see that: for datetime: http://docs.python.org/2/library/datetime.html
and you can find a lot of relevant info's there: http://stackoverflow.com/questions/466345/converting-string-into-datetime
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
About This Community
|Asked: 1/21/14, 9:43 PM|
|Seen: 2310 times|
|Last updated: 3/16/15, 8:10 AM|