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)
 SQL TOP function problem

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-01-10 : 08:14:12
Rodrigo writes "Hello,
I have the following SQL function running here: http://www.jmpromocoes.com.br/agenda.asp

RS.Open "SELECT TOP 7 * FROM NOTICIA ORDER BY noticia_data ASC", DB

noticia_data is the date when the field was registered

I want to show only the dates that are >= from today, then i used this:

if day(RS("noticia_data")) >= day(date) then Response.Write ...

But, if today is january 2, and there's two dates from january 1, it will show only 5 dates in my result page.

So, how can i call that function to show correctly the TOP 7 (i mean, 7 results with only today or future dates), don't considering and don't showing the past dates?

Hope u did understand my question!

Thanks a lot."

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-01-10 : 08:22:15

SELECT TOP 7 * FROM NOTICIA
where DateDiff(day,getdate(),noticia_data)>=0
ORDER BY noticia_data ASC

Also refer this
http://www.sql-server-performance.com/fk_datetime.asp

Madhivanan

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

- Advertisement -