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
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 Need to get yesterday's Data

Author  Topic 

sr832
Starting Member

2 Posts

Posted - 2010-08-27 : 17:22:09
I am trying to get the data only yesterday's data.
Its working through management Studio but SSIS is not working
select * FROM Table
WHERE datefield >= GETDATE() - 2

in SSIS
select * from table where (Datefield = { d '2010-08-26' }) - working but not able to get yesterday's date.

I am new to SQL server and SSIS, can any one please help me on this.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-08-28 : 02:18:17
[code]select * FROM Table
WHERE datefield >=DATEADD(dd,DATEDIFF(dd,0,GETDATE())-1,0)
AND datefield <DATEADD(dd,DATEDIFF(dd,0,GETDATE()),0)
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sr832
Starting Member

2 Posts

Posted - 2010-08-30 : 13:54:01
Actually this query working in Management Studio;
select * from table WHERE (CONVERT(Varchar, EventDate, 101) > GETDATE() - 2) AND (CONVERT(Varchar, EventDate, 101) < GETDATE() - 1)

but i tried yours in SSIS, its not working. The Datefield (Eventdate data type is a DateTime
Go to Top of Page
   

- Advertisement -