DateDiff() quick question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Brita
    New Member
    • Aug 2007
    • 12

    #1

    DateDiff() quick question

    You guys have been life savers for me, and I appreciate your help so much.

    I am trying to check the difference in days between two submitted requests.

    Code:
    DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM);
    Date firstDate = df.parse(firstRequest);
    Date secondDate = df.parse(secondRequest);
    int requestDays = DateDiff(dd, firstDate, secondDate);
    I get an error that dd can not be resolved.
    I tried "DD" and got DateDiff(String , Date, Date) is undefined
    I tried Calendar.DATE and got DateDiff(int, Date, Date) is undefined

    What do I need to add to make this work?

    Thanks again for all your help.

    Brita
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by Brita
    You guys have been life savers for me, and I appreciate your help so much.

    I am trying to check the difference in days between two submitted requests.

    Code:
    DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM);
    Date firstDate = df.parse(firstRequest);
    Date secondDate = df.parse(secondRequest);
    int requestDays = DateDiff(dd, firstDate, secondDate);
    I get an error that dd can not be resolved.
    I tried "DD" and got DateDiff(String , Date, Date) is undefined
    I tried Calendar.DATE and got DateDiff(int, Date, Date) is undefined

    What do I need to add to make this work?

    Thanks again for all your help.

    Brita
    Use the GregorianCalend ar. It has methods that can do what you want. Just open the API specs for it and see.

    Comment

    • Brita
      New Member
      • Aug 2007
      • 12

      #3
      Originally posted by r035198x
      Use the GregorianCalend ar. It has methods that can do what you want. Just open the API specs for it and see.
      Thanks! I used the GregorianCalend ar like you suggested and it works just fine.

      I still am a little confused by DataDiff() though. Is this a standard Java Function? If not why do I keep seeing it everywhere?

      Thanks again.

      Brita

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by Brita
        Thanks! I used the GregorianCalend ar like you suggested and it works just fine.

        I still am a little confused by DataDiff() though. Is this a standard Java Function? If not why do I keep seeing it everywhere?

        Thanks again.

        Brita
        Tell you the truth I've just started to see it now in your code.
        One thing is certain. It's not a standard Java function.
        It's probably a method someone wrote in some Date utils class of theirs.

        Comment

        • Brita
          New Member
          • Aug 2007
          • 12

          #5
          Originally posted by r035198x
          Tell you the truth I've just started to see it now in your code.
          One thing is certain. It's not a standard Java function.
          It's probably a method someone wrote in some Date utils class of theirs.
          You are probably (certainly) correct.

          Thanks again for your help. This is such a great resource. Hopefully, one day I will know enough to help others here.

          Brita

          Comment

          Working...