Select ads if they expired 30+ days ago.

Discussion in 'PHP' started by qwikad.com, Nov 7, 2017.

  1. #1
    This will select all expired ads:

    $sql = "SELECT adid FROM $t_ads WHERE expireson < NOW()";

    I need to selected ads if they expired 30+ days ago.

    How would you do that?

    Thanks!
     
    qwikad.com, Nov 7, 2017 IP
  2. hdewantara

    hdewantara Well-Known Member

    Messages:
    538
    Likes Received:
    47
    Best Answers:
    25
    Trophy Points:
    155
    #2
    hdewantara, Nov 7, 2017 IP
  3. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    7,279
    Likes Received:
    1,696
    Best Answers:
    31
    Trophy Points:
    475
    #3
    That example wanted to select all records. Not sure why.

    This worked though: $sql = "SELECT adid FROM $t_ads WHERE expireson < NOW() - INTERVAL 30 DAY";
     
    qwikad.com, Nov 8, 2017 IP
  4. sarahk

    sarahk iTamer Staff

    Messages:
    28,807
    Likes Received:
    4,534
    Best Answers:
    123
    Trophy Points:
    665
    #4
    What type of column is expireson?

    You probably also want to limit how far back you go - say, another 30 days - to target the recently expired.
     
    sarahk, Nov 8, 2017 IP
  5. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    7,279
    Likes Received:
    1,696
    Best Answers:
    31
    Trophy Points:
    475
    #5
    I don't want to limit. As long as they expired 30+ days ago I want to select (and then remove) them all to keep my db clean from the old, expired ads. If somebody didn't care to renew their ads for 30+ days, they probably don't care if they ever renew them.
     
    qwikad.com, Nov 8, 2017 IP
  6. sarahk

    sarahk iTamer Staff

    Messages:
    28,807
    Likes Received:
    4,534
    Best Answers:
    123
    Trophy Points:
    665
    #6
    All good, I wondered if you were doing some "win back" marketing.
     
    sarahk, Nov 8, 2017 IP
  7. NetStar

    NetStar Notable Member

    Messages:
    2,471
    Likes Received:
    541
    Best Answers:
    21
    Trophy Points:
    245
    #7
    There's just 6 ads...
     
    NetStar, Nov 16, 2017 IP
  8. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    7,279
    Likes Received:
    1,696
    Best Answers:
    31
    Trophy Points:
    475
    #8
    Ahem. There were 30K+ expired ads. Some of them expired over a year ago, it was time to get rid of them.
     
    qwikad.com, Nov 21, 2017 IP