Solved

sql 2005 query

Posted on 2007-11-25
2
138 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Grid querry results 41 72
SQL Database connect change in Access 2015 5 51
How to SQL Trace a SPECIFIC query 24 58
Update in Sql 7 30
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…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
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…

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now