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

Conditional Statements in a query 1

Status
Not open for further replies.

eddmon

Programmer
Apr 2, 2002
10
0
0
US
I have a traditional query in SQL Server 2000 with the SELECT, FROM, WHERE, and ORDERBY. However, when I go to add particular conditions like: if (([a certain date field]<=Date()) Then ([a certain date field]=([another date field]+[a time duration field]));
However, I just can't seem to get the program to like it.
 
In SQL Server, you must use a CASE statement in a query rather than a IF. See SQL Books Online for details.

[a certain date field]=
Case
When [a certain date field]<=getdate()
Then [another date field]+[a time duration field]
Else [Yet another date field]
End

Your query looks more like Access Jet SQL. If that is the case, post your question in forum701: Microsoft: Access Queries and JET SQL.
Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains &quot;Suggestions for Getting Quick and Appropriate Answers&quot; to your questions.
 
Terry:
Thank you and you're right. I've recently entered into the SQL world after many years in ACCESS. I'm currently in a SQL Server 2000 Programming course at college.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top