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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple query with GetDate 1

Status
Not open for further replies.

JohnShell

Technical User
Aug 29, 2003
35
US
Hi,

Have table with one column "dateRequested" which is the current date and another column "reqDecision" which is boolean (yes/no or null if not entered). I want to query those columns and get the fields that are the current date minus one day and "reqDecision" equals "null".
How is that done?

Thanks - John
 
Code:
declare @Yesterday datetime, @Today datetime
select @Yesterday = dateadd(day,datediff(DAY,'20100102',GETDATE()),'20100101'),
@Today = dateadd(day,datediff(DAY,'20100101',GETDATE()),'20100101')

select * from Table where DateRequested >=@Yesterday and
DateRequested < @Today and reqDecision IS NULL

PluralSight Learning Library
 
Markros,

Many thanks. I will try this tomorrow.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top