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 |
|
Slason
Starting Member
3 Posts |
Posted - 2011-11-02 : 05:44:04
|
Hello,I am working on a school project, and I am making a website which observes weather. I am saving each "observation" in my database. I am listing all observations up on a page, and I want the user to have the ability to filter them by date. I am thinking of having a textfield up, which filters all observations by date. I am currently using this code: SELECT *FROM observationsWHERE (date BETWEEN '' AND '') How do I modify the code that I can use a form on the webpage, that specifies what should stand between the ' ' ?Any help would be appreciated . |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-02 : 05:47:23
|
make two date parameters @StartDate and @EndDate of type dateand use likeSELECT *FROM observationsWHERE (date BETWEEN @StartDate AND @EndDate )in case you want to consider time also then make datatype datetime and use likeSELECT *FROM observationsWHERE (date >=@StartDate AND date < @EndDate+1 ) ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|