Check a date on a DB2 table to see if it falls within the last 24 hours.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sam1221
    New Member
    • Jan 2016
    • 1

    #1

    Check a date on a DB2 table to see if it falls within the last 24 hours.

    The date is in datetime format. I need to do this check in a SQL join statement, but my results don't appear correct.

    Code:
    SELECT emp_ID, emp_EFF_DT
    FROM EMP_EMPLOYEE
    left outer join INS_COVERAGE ON emp_ID = ins_ID and
     current time > emp_EFF_DT  and
    ((current time - 24 hours) < emp_EFF_DT)
    Last edited by zmbd; Jan 5 '16, 08:41 PM. Reason: [z{placed code formatting}]
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Probably because the date restriction needs to go in the WHERE clause and not the JOIN clause. But you don't provide enough information for us to diagnose the exact issue.

    Comment

    Working...