Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Yesterday to Today

Author  Topic 

kwazzle
Starting Member

2 Posts

Posted - 2009-11-12 : 13:55:47
Hi I'm pretty new to SQL and I'm having some serious difficulty on writing a script that will have this report run from yesterday to today at a certain time 10AM, showing results within that 24 hour period.
Please help! Thanks!

X002548
Not Just a Number

15586 Posts

Posted - 2009-11-12 : 13:58:13
...all my troubles seemed so far away...now I need...

Umm Post some DDL, sample data and what the results are suppose to look like

My esp usb port is clogged



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

rdeavers
Starting Member

2 Posts

Posted - 2009-11-12 : 14:05:53
You're probably running esp usb 1.0. If you upgrade to 2.0, that should fix the problem.
Go to Top of Page

kwazzle
Starting Member

2 Posts

Posted - 2009-11-12 : 14:05:55
SELECT *
FROM my.table

WHERE declare @yesterday datetime;
declare @today datetime;

set @yesterday = current_timestamp;


datefield >= DATEADD(mm,DATEDIFF(mm,0,CURRENT_TIMESTAMP-1),0)
and datefield < DATEADD(mm,DATEDIFF(mm,0,CURRENT_TIMESTAMP-1)+1,0)


ORDER BY *
go

I was thinking about using the DATEADD or GETDATE but both times I try, I get the random day I set for it. Results are supposed to be this report and it has a date/time column if that helps.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2009-11-13 : 09:57:56
Is this what you want?

SELECT GetDate() AS Now, DATEADD(dd,-1,GetDate()) AS Yesterday




Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -