Solved

sql 2005 query

Posted on 2007-11-25
2
140 Views
Last Modified: 2010-03-19
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
0
Comment
Question by:romeiovasu
2 Comments
 
LVL 35

Accepted Solution

by:
David Todd earned 250 total points
ID: 20347712
Hi,

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

HTH
  David
0
 
LVL 6

Assisted Solution

by:PaultheBroker
PaultheBroker earned 250 total points
ID: 20347792
where [date] > dateadd(datediff(day,0,getdate()),-5)

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

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes some very basic things about SQL Server filegroups.
SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question