Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get data from only past 5 days

Status
Not open for further replies.

mistektips

Programmer
Apr 4, 2006
20
0
0
US
Hi,

I have to write a query which gets data only from past 5 days from a table. This table has a column for date.
Could someone suggest how do I write the query.

Thanks!
 
Code:
-- at most 5 days from this moment (time included)
select ...
from myTable
where dateColumn >= getdate() - 5

-- at most 5 days, starting with midnight
select ...
from myTable
where dateColumn >= dateadd(dd, -5, datediff(dd, 0, getdate()))

------
[small]select stuff(stuff(replicate('<P> <B> ', 14), 109, 0, '<.'), 112, 0, '/')[/small]
[banghead]
 
Thanks Vongrunt. However, I am trying to get data from past 5 days from AS/400 database. The date format there is different. So when i tried the above mentioned way, it doesnt work.
Could anyone suggest plz?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top