1

I am new to SQL. I have a table which contains information about ads. Which function should I use, to find id of all ads posted within the past three days?

Vaibhav Jain
  • 33,887
  • 46
  • 110
  • 163
Marshall Black
  • 87
  • 2
  • 3
  • 10

2 Answers2

1
Select ID --the id field
From tblAds --the ads table
WHERE Ad_Date >= DATEADD(day,-3,getDate()) --the filter. I am assuming Ad-Date is the name of the ad's date field
order by Ad_Date ASC -- order it
Captain Kenpachi
  • 6,960
  • 7
  • 47
  • 68
1

For Oracle DB, use this,

SELECT id
FROM tablename
WHERE TRUNC(pdate) >= TRUNC(SYSDATE) - 3;

SQLFIDDLE DEMO

Orangecrush
  • 1,970
  • 2
  • 15
  • 26