Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2002
    Madrid - Spain
    Provided Answers: 1

    Unanswered: select records in table with today -n days.

    Hi colleagues,

    I have a table xxxx with field date_created with field data type TIMESTAMP, i need select the records where date_created = today -10 days.

    what is the sentence for todo this output?

    Thank you for advanced.

  2. #2
    Join Date
    Apr 2006
    Provided Answers: 11
    date(date_created) = current date -10 days

    if this is the only predicate it might be that index on this col is not used, because of the function
    Best Regards, Guy Przytula
    Database Software Consultant
    Good DBAs are not formed in a week or a month. They are created little by little, day by day. Protracted and patient effort is needed to develop good DBAs.
    Spoon feeding : To treat (another) in a way that discourages independent thought or action, as by overindulgence.
    DB2 UDB LUW Certified V7-V8-V9-V9.7-V10.1-V10.5-V11 Fundamentals- DB Admin - Advanced DBA -Dprop..
    Information Server Datastage Certified

  3. #3
    Join Date
    May 2009
    Provided Answers: 1
    If date_created is indexed, you can use the Timestamp function like this:
    WHERE date_created BETWEEN TIMESTAMP(CURRENT_DATE, '00.00.00') - 10 DAYS 
                           AND TIMESTAMP(CURRENT_DATE, '24.00.00') - 10 DAYS

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts