Date Comparison

Discussion in 'Python' started by mohana2004@gmail.com, Feb 3, 2009.

  1. Guest

    Hi,
    I need to compare two dates and find the number of days between those
    two dates.This can be done with datetime module in python as below,
    but this is not supported in Jython.

    example
    from datetime import date
    a=datetime.date(2009,2,1)
    b=datetime.date(2008,10,10)
    c= a-b
    c.days
    114

    Is there any other function to do the same(should be supported by
    Jython)

    Regards,
    Monyl
    , Feb 3, 2009
    #1
    1. Advertising

  2. wrote:

    > Hi,
    > I need to compare two dates and find the number of days between those
    > two dates.This can be done with datetime module in python as below,
    > but this is not supported in Jython.
    >
    > example
    > from datetime import date
    > a=datetime.date(2009,2,1)
    > b=datetime.date(2008,10,10)
    > c= a-b
    > c.days
    > 114
    >
    > Is there any other function to do the same(should be supported by
    > Jython)


    Use the java API of java.util. That methods like before and after on
    date-objects.

    Diez
    Diez B. Roggisch, Feb 3, 2009
    #2
    1. Advertising

  3. Bill McClain Guest

    Bill McClain, Feb 3, 2009
    #3
  4. 2009/2/3 Diez B. Roggisch <>:
    > Use the java API of java.util.


    Or better still, use Joda.

    --
    Cheers,
    Simon B.
    Simon Brunning, Feb 3, 2009
    #4
  5. Simon Brunning wrote:

    > 2009/2/3 Diez B. Roggisch <>:
    >> Use the java API of java.util.

    >
    > Or better still, use Joda.
    >


    "dates compare you must?"

    SCNR. Didn't know of this incarnation of him...

    Diez
    Diez B. Roggisch, Feb 3, 2009
    #5
  6. Mark Wooding Guest

    writes:

    > I need to compare two dates and find the number of days between those
    > two dates.This can be done with datetime module in python as below,
    > but this is not supported in Jython.
    >
    > example
    > from datetime import date
    > a=datetime.date(2009,2,1)
    > b=datetime.date(2008,10,10)
    > c= a-b
    > c.days
    > 114


    I don't understand your problem.

    Jython 2.2.1 on java1.6.0_0
    Type "copyright", "credits" or "license" for more information.
    >>> from datetime import date
    >>> a=datetime.date(2009,2,1)
    >>> b=datetime.date(2008,10,10)
    >>> c = a - b
    >>> c.days

    114

    -- [mdw]
    Mark Wooding, Feb 3, 2009
    #6
  7. Bill McClain wrote:
    > On 2009-02-03, <> wrote:
    >> Hi,
    >> I need to compare two dates and find the number of days between those
    >> two dates.This can be done with datetime module in python as below,
    >> but this is not supported in Jython.

    >
    > There are julian day routines in this astronomy package:
    >
    > http://astrolabe.sourceforge.net/

    and in Mark Lemburg's mxDate

    Colin W.
    >
    > -Bill
    Colin J. Williams, Feb 4, 2009
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    1
    Views:
    597
    Matthew Speed
    Nov 8, 2003
  2. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,250
    Michael Borgwardt
    May 30, 2004
  3. Matt
    Replies:
    2
    Views:
    515
    Pete Becker
    Nov 8, 2003
  4. Matt
    Replies:
    3
    Views:
    719
    Richard Heathfield
    Nov 8, 2003
  5. Deepu
    Replies:
    1
    Views:
    237
    ccc31807
    Feb 7, 2011
Loading...

Share This Page