sql 2005 query

i have a table with list of data.

i want to get the data from last 5 days using query order by date.
table structure is
itemid
itemname
date
datecreated
username

so i want to get a data based on date for last 5 days
romeiovasuAsked:
Who is Participating?
 
David ToddConnect With a Mentor Senior DBACommented:
Hi,

select
  itemID
  , itemname
  , [date]
  , datecreated
  , username
from dbo.sometable
where [date] > dateadd( dd, -1, getdate() )
order by
  [date]

HTH
  David
0
 
PaultheBrokerConnect With a Mentor Commented:
where [date] > dateadd(datediff(day,0,getdate()),-5)

otherwise it will be exactly five days ago (120 hours)
0
All Courses

From novice to tech pro — start learning today.