DATE function problems

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Corky

    DATE function problems

    This works:

    db2 SELECT DISTINCT PROBLEM_OBJECTS .PROBLEM_ID FROM PROBLEM_OBJECTS
    INNER JOIN PROBLEMS ON PROBLEM_OBJECTS .PROBLEM_ID =
    PROBLEMS.PROBLE M_ID WHERE INTEGER(DAYS(CU RRENT DATE) -
    DAYS(PROBLEMS.C LOSE_DATE)) = 365 AND PROBLEMS.CLOSE_ DATE IS NOT NULL

    But this doesn't:

    db2 SELECT DISTINCT PROBLEM_OBJECTS .PROBLEM_ID FROM PROBLEM_OBJECTS
    INNER JOIN PROBLEMS ON PROBLEM_OBJECTS .PROBLEM_ID =
    PROBLEMS.PROBLE M_ID WHERE INTEGER(DAYS(CU RRENT DATE) -
    DAYS(PROBLEMS.C LOSE_DATE)) > 365 AND PROBLEMS.CLOSE_ DATE IS NOT NULL

    The only difference is the comparison operator ( = vs. > )

    Any ideas?

    Thanks in advance,

    Corky
  • Mark A

    #2
    Re: DATE function problems

    "Corky" <mowere@konicab t.com> wrote in message
    news:7e5571df.0 312031235.12288 8c5@posting.goo gle.com...[color=blue]
    > This works:
    >
    > db2 SELECT DISTINCT PROBLEM_OBJECTS .PROBLEM_ID FROM PROBLEM_OBJECTS
    > INNER JOIN PROBLEMS ON PROBLEM_OBJECTS .PROBLEM_ID =
    > PROBLEMS.PROBLE M_ID WHERE INTEGER(DAYS(CU RRENT DATE) -
    > DAYS(PROBLEMS.C LOSE_DATE)) = 365 AND PROBLEMS.CLOSE_ DATE IS NOT NULL
    >
    > But this doesn't:
    >
    > db2 SELECT DISTINCT PROBLEM_OBJECTS .PROBLEM_ID FROM PROBLEM_OBJECTS
    > INNER JOIN PROBLEMS ON PROBLEM_OBJECTS .PROBLEM_ID =
    > PROBLEMS.PROBLE M_ID WHERE INTEGER(DAYS(CU RRENT DATE) -
    > DAYS(PROBLEMS.C LOSE_DATE)) > 365 AND PROBLEMS.CLOSE_ DATE IS NOT NULL
    >
    > The only difference is the comparison operator ( = vs. > )
    >
    > Any ideas?
    >
    > Thanks in advance,
    >
    > Corky[/color]

    I don't know the answer to your question, but I don't understand why you are
    using the integer function since the days function returns the value in
    integer format.

    When you say "does not work." Does that mean you get an error or no data
    returned.


    Comment

    • Serge Rielau

      #3
      Re: DATE function problems

      You working on some Mars-Probe? On Earth 365 is pretty much all you get
      in a year....

      Cheers
      Serge
      --
      Serge Rielau
      DB2 SQL Compiler Development
      IBM Toronto Lab

      Comment

      • Mark A

        #4
        Re: DATE function problems

        "Serge Rielau" <srielau@ca.e ye-bee-m.com> wrote in message
        news:bqltme$jij $2@hanover.toro lab.ibm.com...[color=blue]
        > You working on some Mars-Probe? On Earth 365 is pretty much all you get
        > in a year....
        >
        > Cheers
        > Serge
        > --
        > Serge Rielau
        > DB2 SQL Compiler Development
        > IBM Toronto Lab
        >[/color]
        What about leap years?


        Comment

        • Serge Rielau

          #5
          Re: DATE function problems

          Hmmm, I just had this one backfire on me, eh?


          --
          Serge Rielau
          DB2 SQL Compiler Development
          IBM Toronto Lab

          Comment

          • Knut Stolze

            #6
            Re: DATE function problems

            Mark A <ma@switchboard .net> wrote:
            [color=blue]
            > "Serge Rielau" <srielau@ca.e ye-bee-m.com> wrote in message
            > news:bqltme$jij $2@hanover.toro lab.ibm.com...[color=green]
            >> You working on some Mars-Probe? On Earth 365 is pretty much all you get
            >> in a year....
            >>[/color]
            > What about leap years?[/color]

            And don't forget that there is more than just one year...

            Anyway, what is the exact error message that is returned by DB2 on the "not
            working" query?

            --
            Knut Stolze
            Information Integration
            IBM Germany / University of Jena

            Comment

            Working...