Gossamer Forum
Home : General : Databases and SQL :

SQL query (with date)

Quote Reply
SQL query (with date)
 
SELECT Processed_By as User, COUNT(Processed_By) as Count FROM Data WHERE Processed_Date >= '2004-1-1' And Processed_Date <= '2004-3-2' GROUP BY Processed_By ORDER BY Count DESC;

Doesn't show the statistics between the beginning of this year and yesterday. If I use 2004-3-3 (today) as enddate it works fine. But maybe that this search query can be done easier or more accurate?
Quote Reply
Re: [cK] SQL query (with date) In reply to
What RDBMS are you using?

MySQL, SQL Server, Access?

That would help in terms of providing suggestions on improving the query.

Also, what is the column/field type for the <b>Processed_Date</b>?

Date, Datetime, Timestamp, etc.?

That will also help with providing suggestions for improving the query.
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [Stealth] SQL query (with date) In reply to
Offcourse..It's MS SQL : datetime.

But looking up this info made me realize that 3-3-2004 is converted to 3-3-2004 00:00, meaning I NEED to use < 4-3-2004 (=4-3-2004 00:00).

So thank you very much for answering the question without answering the question ;-)