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!

query for yesterdays data ?

Status
Not open for further replies.

richardmorrison

IS-IT--Management
Jun 20, 2001
9
GB
I need to be able to have SQL query a database for all yesterdays data - the date () -1 doesn't do it and the getdate () -1 either ?

I have seen some of the posts on here and know somebody must have come across this before ?
 
Try using WHERE myDate < date() AND myDate > date()-2.

HTH

Muttley

 
select movement_date from st_history where movement_date < date() AND movement_date > date()-2 and warehouse = 'C1'


Try using WHERE myDate < date() AND myDate > date()-2.


the top one is what i have just tried - do i have to define &quot;mydate&quot; ?? - I'm fairly new to SQL so be gentle !

 
you should use
if datediff(dd,date(),mydate)<1 and datediff(dd,date(),mydate)>-1 John Fill
1c.bmp


ivfmd@mail.md
 
Sorry Richard, should have stated - I was using myDate as the placeholder for whatever date you wanted to test against date().

What you posted looks OK, but If you are not having any luck with my or JohnFills suggestion, I suggest that you try and build iteratively (i.e. first test that you have movement_date < date(), THEN that that you have movement_date > date()-2 etc. (If that isn't teaching you to suck eggs!).

Muttley

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top