473,320 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Querying for rows belonging to a month

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.

Feb 26 '07 #1
3 826
On Feb 26, 11:11 pm, mavrick_101
<mavrick...@discussions.microsoft.comwrote:
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'

Feb 26 '07 #2
mavrick_101 wrote:
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'

--
Göran Andersson
_____
http://www.guffa.com
Feb 27 '07 #3
Alexey Smirnov wrote:
On Feb 26, 11:11 pm, mavrick_101
<mavrick...@discussions.microsoft.comwrote:
>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'
I know that february is a short month, but isn't that cutting it a bit
too short? ;)

--
Göran Andersson
_____
http://www.guffa.com
Feb 27 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: toedipper | last post by:
Hello, MYsql and PHP If I want to extract data with todays date then it's 'where blab blah = current_date()' For yesterday it's 'where blah blah = current_date()-1' But can anyone tell...
5
by: Shane | last post by:
I wonder if someone has any ideas about the following. I am currently producing some reports for a manufacturing company who work with metal. A finished part can contain multiple sub-parts to...
3
by: MDB | last post by:
I'd normally Google for a question like this, and hope to snag a few examples along with the answer, but this time I can't see to get the keywords specific enough. Or I'd ask coworkers, but...
6
by: Tony | last post by:
The w3schools HTML tag reference for <textarea> http://www.w3schools.com/tags/tag_textarea.asp says that the attributes 'cols' and 'rows' are REQUIRED attributes for the textarea tag. Looking at...
2
by: avanti | last post by:
Hi, I am trying to delete rows from a TableLayoutPanel at Runtime. I tried editing the RowStyles collection but doesn't do what I want it to. I have a table with 10 rows. I want to delete rows 2...
5
by: sql_er | last post by:
Guys, I have an XML file which is 233MB in size. It was created by loading 6 tables from an sql server database into a dataset object and then writing out the contents from this dataset into an...
3
by: Shokoth | last post by:
Hi all I am trying to run a query, that brings me back all the jobs done in a month.. currntly the month in stored as 00-XXX-07. so its like 10-apr-07. i am trying to run a query that will bring...
2
by: Blasting Cap | last post by:
I've got a gridview (that I converted over from a datagrid, which had been working properly), that is doubling up the number of rows returned. When it was running as a datagrid, the same code sent...
2
by: RajSharma | last post by:
Hi, I am facing a problem regarding querying thru a large table having millions of rows....... Its hanging in between while querying for all those rows Can anybody suggest me a query regarding :...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.