Querying for rows belonging to a month

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a table where I keep information about events. All the events have
start date time and end date time.

I want to get all the events for a month. I tried the following but it
doesn't cover the whole month...

SELECT *
FROM Events
WHERE StartDate between '2/1/2007' AND '2/28/2007'

Whats will be the best way to get this data?

Thanks in advance.
 
Hi,

I have a table where I keep information about events. All the events have
start date time and end date time.

I want to get all the events for a month. I tried the following but it
doesn't cover the whole month...

SELECT *
FROM Events
WHERE StartDate between '2/1/2007' AND '2/28/2007'

Whats will be the best way to get this data?

Thanks in advance.

try

WHERE StartDate between '2007-02-01' AND '2007-02-01'
 
mavrick_101 said:
Hi,

I have a table where I keep information about events. All the events have
start date time and end date time.

I want to get all the events for a month. I tried the following but it
doesn't cover the whole month...

SELECT *
FROM Events
WHERE StartDate between '2/1/2007' AND '2/28/2007'

Whats will be the best way to get this data?

Thanks in advance.

The between keyword uses inclusive comparison on both arguments. To get
it right the first comparison should be inclusive and the second
comparison should be exclusive:

WHERE StartDate >= '2007-02-01' AND StartDate < '2007-03-01'
 
Alexey said:
try

WHERE StartDate between '2007-02-01' AND '2007-02-01'

I know that february is a short month, but isn't that cutting it a bit
too short? ;)
 
Back
Top