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.
| 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 DateSince YesterdaySince 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 procDaniel Small MIAPwww.danielsmall.com IT Factoring |
 |
|
|
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 ThanksthiruEdited by - thiruna on 07/10/2002 06:28:00 |
 |
|
|
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_nameWHERE @nodays = 0When you pass 0, that would be interpreted as Any Date.HTHDaniel Small MIAPwww.danielsmall.com IT Factoring |
 |
|
|
thiruna
Starting Member
41 Posts |
Posted - 2002-07-10 : 09:04:52
|
| thanks danny... |
 |
|
|
|
|
|