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 2000 Forums
 SQL Server Development (2000)
 Selecting records from the last week.....

Author  Topic 

pmidge
Starting Member

2 Posts

Posted - 2009-06-22 : 08:29:26
Hello.

I wondered if someone could help me. I am having trouble trying to write a sql query which will select all records imported in the last week, but only those imported after a specific time.

So, I have a column called import_date, and the query I have so far is -

select id, email, import_date, source
from advertiser_unsubscribe_log
where import_date >= dateadd(dd, -6, getdate())
order by import_date

Which gives me everything from the last week (from last Tuesday until today). I now want to narrow down my selections even further, by selecting only records imported after 12pm last Tuesday.


Any help would be great.

Thanks

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-06-22 : 08:37:23
Try

select id, email, import_date, source
from advertiser_unsubscribe_log
where import_date >= dateadd(day, datediff(day,0, getdate())-6,'12:00:00')
order by import_date


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -