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)
 Filtering records by date as used in Snitz....?

Author  Topic 

thiruna
Starting Member

41 Posts

Posted - 2002-07-10 : 03:21:41
Hi,

When you look at the Snitz search ...It gives as the option of

Any Date
Since Yesterday
Since 2 days ago...etc...

How could we write a stored procedure.....?

I have tried the following....

SELECT (column list) FROM Table_name
WHERE datediff(dd, datefield, getdate()) > 2 (or whatever)...

Will it work or can this programmed in one line of code so whatever they choose will and also if they choose Any date...how we could write a programm to return all the records...?



MakeYourDaddyProud

184 Posts

Posted - 2002-07-10 : 05:50:51
in your where clause...
quote:

WHERE datediff(dd, datefield, getdate()) > 2 ...



could be parameterised thus...

WHERE datediff(dd, datefield, getdate()) > @nodays ...

and @nodays could be a passed parameter to a stored proc


Daniel Small MIAP
www.danielsmall.com IT Factoring
Go to Top of Page

thiruna
Starting Member

41 Posts

Posted - 2002-07-10 : 06:26:10
if the user chooses "Any Date" Option...
how would the same query be


Thanks
thiru



Edited by - thiruna on 07/10/2002 06:28:00
Go to Top of Page

MakeYourDaddyProud

184 Posts

Posted - 2002-07-10 : 08:12:55
in your stored procedure prior to the select add the following:

SELECT @nodays = datediff(dd, min(datefield), getdate())
FROM Table_name
WHERE @nodays = 0

When you pass 0, that would be interpreted as Any Date.

HTH

Daniel Small MIAP
www.danielsmall.com IT Factoring
Go to Top of Page

thiruna
Starting Member

41 Posts

Posted - 2002-07-10 : 09:04:52
thanks danny...


Go to Top of Page
   

- Advertisement -