jmoisan Posted January 26, 2002 Share Posted January 26, 2002 Hi there, I started programming queries with MSSQL Server 2000, and I have a question for you guys. I need a query that returns the next activity (in date from now) from a list of activities in a SQL database. ****************** Example : SELECT TOP 1 Date, Activity FROM dbo.Activities WHERE ??????? ORDER BY Date ****************** How the hell am I supposed to write it ? I would really appreciate if you guys could send me the correct syntax. THANKS A LOT ! Link to comment Share on other sites More sharing options...
0 gregor Posted January 27, 2002 Share Posted January 27, 2002 where date>todays_date if you know what i mean.. you want only one selection from db where date is greater than today's date? if so,... where date>todays_date limit 0,1 Link to comment Share on other sites More sharing options...
0 jmoisan Posted January 27, 2002 Author Share Posted January 27, 2002 I tried what you said, but it doesn't seem to work... am I missing something here ? The only thing I need in fact is a way to return today's date : I tried the "Today ()" or "GetDate ()" variables, but my system refuses to valid my syntax. After that, I tried this : SELECT TOP 1 Date, Titre FROM dbo.Activit?s WHERE dateDiff("dd",Date,getdate())<=0 The syntax is OK, but when I try to save the query I get an ADO error for misusing the GetDate() function ??? I'M STUCK. Could someone help me ? Link to comment Share on other sites More sharing options...
0 iUk Posted February 1, 2002 Share Posted February 1, 2002 Try using Date() to get today's date. Works for me... Link to comment Share on other sites More sharing options...
Question
jmoisan
Hi there,
I started programming queries with MSSQL Server 2000, and I have a question for you guys.
I need a query that returns the next activity (in date from now) from a list of activities in a SQL database.
******************
Example :
SELECT TOP 1 Date, Activity
FROM dbo.Activities
WHERE ???????
ORDER BY Date
******************
How the hell am I supposed to write it ? I would really appreciate if you guys could send me the correct syntax.
THANKS A LOT !
Link to comment
Share on other sites
3 answers to this question
Recommended Posts