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)
 Date Diff

Author  Topic 

macca
Posting Yak Master

146 Posts

Posted - 2008-06-17 : 07:35:39
WHERE (g_date >= DATEADD([day], DATEDIFF([day], 0, GETDATE()) - 7, 0))

The above code returns for me everything with a g_date in the past 7 days but it also returns anything with a g_date after today, some apps have been assigned a g_date in advance e.g. 20/06/2008.

Does anyone know how I can changed the above code so that it only returns everything with a g_date in the lat 7 days up to today but nothing after today i.e. nothing with advanced dates.

Thanks,
macca

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2008-06-17 : 07:44:19
WHERE g_date >= DATEADD([day], DATEDIFF([day], 0, GETDATE()) - 7, 0)
and g_date <= DATEADD([day], DATEDIFF([day], 0, GETDATE()), 0)
Go to Top of Page

macca
Posting Yak Master

146 Posts

Posted - 2008-06-17 : 08:13:32
Thanks RickD that worked a treat.
Go to Top of Page
   

- Advertisement -