November 19, 2003 at 9:46 am
Hello, Thanks for taking the time to read and think about this.
Here is my problem. I have a CalendarEvent
table which amongst others has start_date_time and end_date_time columns
Either field can contain a short date such as
'10/10/2003' or a longer one such as
'10/10/2003 4:00:00 PM'
what i would like to do is select a list of
events for a given day (disregard the time part of the date entry)
So if i had two entries like the ones above
and asked for events on '10/10/2003' i would get them both.
I've achived this effect using rather inelegant (and probably costly) aproach like this:
Select * from CALENDAR_EVENT WHERE DatePart(month,@startDate)=DatePart(month,Start_Date_Time) and DatePart(year,@startDate)=DatePart(year,Start_Date_Time) and DatePart(day,@startDate)=DatePart(day,Start_Date_Time) Order by Start_Date_Time
The question number 1 is:
is there a better way of doing the above?
The question number 2 is:
Would it be possible to select events for days that fall between the start and end dates. For example:
i have an event whose start_date_time is 10/10/2003 and end_date_time is '10/15/2003'
If i pass an argument of 10/13/2003 i would like to get the above event.
How would i go about selecting something like that. I realize i could do that using the same cheesy way shown above but i would like something better. Please help if you can.
November 19, 2003 at 10:18 am
SELECT *
FROM Calendar_Event
WHERE Start_Date_Time >= @StartDate
AND Start_Date_Time < @StartDate + 1
SELECT *
FROM Calendar_Event
WHERE @StartDate BETWEEN Start_Date_Time AND End_Date_Time
--Jonathan
--Jonathan
November 19, 2003 at 10:36 am
Thanks a lot. Exactly what i wanted.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply