Logo 
Search:

Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

Getting a range of values

  Asked By: Nicole    Date: Jun 19    Category: Asp.net    Views: 1033
  

I have a calendar driven application, I would like to know how to compose the following three SQL statements.

Share: 

 

6 Answers Found

 
Answer #1    Answered By: Abrianna Rossi     Answered On: Jun 19

SELECT * from Tablename where date bwtween(@startdate AND @enddate)

@startdate , @enddate will be the two parameters passed from your program as parameter in which you stored values  dates from calender.

I am also not an expert, maybe someone else can further tell a better way.

 
Answer #2    Answered By: Damon Jones     Answered On: Jun 19

I don't see any problem with that but I also need to know how to be able to calculate the beginning of a month (given the month name or month number i.e. being January = 1st month December = 12th month) so that for any month, whether it starts on the 1st and ends on the 30 or the 31st

I can programmatically calculate the start and end date for the current month (and if need be pass the above either the month Number or the month day and calculate the values)

 
Answer #3    Answered By: Varun Mehta     Answered On: Jun 19

clear me something, in your application  user will chosse one date only which may not be the 1st of a certain month but in output you want that to use the chosen date in a way that it should go for the whole month while filtering data?

 
Answer #4    Answered By: Vidhya Iyer     Answered On: Jun 19

The calendar  will load on the current month, I will have a drop down with three options for the users 1. just one calendar with the current month 2. three calendars with the previous month the current month and the month to come 3. Some how all the months in the year with their respective calendars.

Now the data grid is there to show the events in the months, the calendar has all the days with events highlighted with a little caption telling the user what is on that day the data grid has the details.

Now I need to be able to have the data grid filtered by which ever one of the selection the user selects from the three selections above.

Does that clear things up more?

 
Answer #5    Answered By: Alvin Nguyen     Answered On: Jun 19

1. just one calendar  with the current month
Here user willhave all the dates displayed for current month, user click on one and u can display the results for that particular date as:
select * from tablename where date = @choice1date
and
if we assume that in choice 1 user cliked on 2 dates and he wants results between them the
SELECT * from Tablename where date bwtween(@startdate AND @enddate)
and finally
assuming user clicked on the month on any date but you want results is grid for teh whole month then:
select * from Tablename where month(datefieldintable)=@monthnumber
The month number can be obtained from the datetime variable as there is a propert datevar.month.tostring and then a "case select " to give you teh number for the month u got.
2. three calendars with the previous month the current month and the month to come
My understanding regarding this is the from eahc calender user selects two dates and u can display the results between two dates:
SELECT * from Tablename where date bwtween(@startdate AND @enddate)
or
if you want the result as to be for the whole two selected months then:
select * from Tablename where month(datefieldintable) => @startmonthnumber and month(datefieldintable) <= @endmonthnumber

If these assumptions are ok then answer for 3rd can be obtained from above.

 
Answer #6    Answered By: Jackson Bouchard     Answered On: Jun 19

All the calendar  is used for is not to select dates but to have the dates that are reflected in the data grid highlighted as days on the calendar , the filter I am trying to set is for the data grid and a user will not select ANY values  from the calendar I need to calculate the dates as explained below

 
Didn't find what you were looking for? Find more on Getting a range of values Or get search suggestion and latest updates.




Tagged: