Showing posts with label lists. Show all posts
Showing posts with label lists. Show all posts

Tuesday, March 20, 2012

Current month date query

Hi,

I have a simple table called events, which lists the start and end dates of events. I'm using a calendar control that queries the db for events, but at the moment it does a check for every day by passing in the day. (Very inefficient)

What I'd like to do is pass in the current month, and get a set of rows that have an event which is in that month. It sounds easy, but I'm a little confused about what to do if the event starts current month -1 and ends currentmonth +1 I obviously need to return results like these also.

Do you just need something like this:

SELECT *FROM EventTableWHERE EventStartDate <= @.EndOfMonthOR EventEndDate >= @.StartOfMonth

You'll need to pass in the Start and End of Month values, of course. HTH

|||

I assume that you would like to return all events which started or finished in selected month. Maybe you can use Query like this if year is not important.

DECLARE @.tcMonth int

SET @.tcMonth=10 -- events for October

Select *

from Events

where MONTH(StartDate)=@.tcMonth

OR MONTH(EndDate)=@.tcMonth

Thanks

JPazgier

|||

That's great.

I changed the Or to an And though. :-)

|||

If you change OR to AND in this query you will receive only events which started and ended in selected month, with OR you should receive also events which were started earlier and finished in selected month and events which were started in selected month and finished after it.

Thanks

JPazgier

Sunday, February 19, 2012

CTP Expiration Dates

Is there a document that lists the expiration dates of the CTP releases? We've a test box still on CTP15 and I was wondering when the CTP will stop working.
There is no paper that lists them all but I think in 15's case it will be soon, its almost a year since it was released.|||The agreed licence statement in the setup tells you that the CTP will loose it licence when the version is pubslihed, so you should either consider to remove or upgrade your current system.

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de
-