Querying for rows belonging to a month

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.
 
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.

try

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

Guest

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'
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

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? ;)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top