1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Date query

Discussion in 'Databases' started by Solomoncandy, Jul 3, 2015.

  1. #1
    I need to extract the details from today until 6 previous days from the table. Can you help me to form this query?
    SEMrush
     
    Solomoncandy, Jul 3, 2015 IP
    SEMrush
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,630
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    Well, as long as you have a properly formatted date-column, something like "SELECT * FROM tablename WHERE date_column >= date_sub(now(), interval 6 days)" or something like that.
     
    PoPSiCLe, Jul 3, 2015 IP
  3. Taruna P

    Taruna P Greenhorn

    Messages:
    13
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    13
    #3
    SELECT * FROM table WHERE date >= curdate()- INTERVAL DAYOFWEEK(curdate())+6 DAY AND date < curdate()- INTERVAL DAYOFWEEK(curdate())-1 DAY
     
    Taruna P, Jul 6, 2015 IP
  4. Solomoncandy

    Solomoncandy Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #4
    Thanks
     
    Solomoncandy, Jul 17, 2015 IP
  5. SalvadorWilliam

    SalvadorWilliam Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #5
    you can perform following querry for the extraction of details
    select from table_name where column_name < DATE_SUB(NOW(), INTERVAL 6 DAY)
     
    SalvadorWilliam, Jul 24, 2015 IP