compare two date?

Asked by shanky

Hello,

I want compare 2 date.
  'start_date' : fields.date('Start Date'),
  'end_date' : fields.date('End Date')

for obj in self.browse(cr,uid,id):
    if obj.start_date <= obj.end_date:
          print "End Date is big"
However, I try to print obj.end_date and obj.start_date this show me boolean (True,False)value.
and also how to print date.

Thanks

Question information

Language:
English Edit question
Status:
Solved
For:
Odoo Server (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Solved by:
Anup(SerpentCS)
Solved:
Last query:
Last reply:
Revision history for this message
Parthiv Patel (parthiv-patel-deactivatedaccount) said :
#1

it's now part of python code, try to find out python functions or code which
helps for the same. Python datetime library would help in it.

http://docs.python.org/library/datetime.html

On Wed, May 26, 2010 at 11:07 AM, shanky <
<email address hidden>> wrote:

> Question #112287 on OpenObject Server changed:
> https://answers.launchpad.net/openobject-server/+question/112287
>
> Summary changed to:
> compare two date?
>
> --
> You received this question notification because you are an answer
> contact for OpenObject Server.
>

--
Thanks & Regards,
Parthiv Patel

Revision history for this message
Best Anup(SerpentCS) (anup-serpent) said :
#2

Hello Shanky,

   The boolean value will come only when you don't have a value for date in the particular record. When you have values in that object it will definitely print the values. and I have checked we can compare the fields.date directly so no need to make any conversions in other formats.
 And you can directly print the dates as par the conventional printing approach of python as shown in below.

    if obj.start_date < obj.end_date:
          print "End Date is big",obj.start_date,obj.end_date

Revision history for this message
shanky (shankar-shinde-deactivatedaccount) said :
#3

Thanks Anup (Open ERP), that solved my question.