Re: need query: records inserted on Monday?

2007-11-20 Thread Dan Buettner
Afan, you'll need to have a date and time column in the database storing a
created at value, that is set on INSERT and then not changed.

Assuming you have such a column - let's call it created_at - you can run
queries like this:

/* to get count of records created on Mondays */
SELECT COUNT(*)
FROM table t
WHERE DAYOFWEEK(t.created_at) = 2;

/* to get count created on a given date between 8 AM and 4 PM */
SELECT COUNT(*)
FROM table t
WHERE t.created_at = 2007-11-20 8:00
AND t.created_at = 2007-11-20 16:00;

MySQL's docs on date and time functions are here:
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html

HTH,
Dan




On Nov 20, 2007 12:16 PM, Afan Pasalic [EMAIL PROTECTED] wrote:

 Hi,
 I have to build a report - when (date and/or time) the records are
 inserted. E.g., number of records inserted on Monday - doesn't matter
 what month.
 Or, number of records inserted on specific date between 8am and 4pm.

 Thanks for any help.

 -afan


 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]




need query: records inserted on Monday?

2007-11-20 Thread Afan Pasalic

Hi,
I have to build a report - when (date and/or time) the records are 
inserted. E.g., number of records inserted on Monday - doesn't matter 
what month.

Or, number of records inserted on specific date between 8am and 4pm.

Thanks for any help.

-afan


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: need query: records inserted on Monday?

2007-11-20 Thread Afan Pasalic

Yup! That's it!
Thanks Dan.
;)

The link is really helpful. I was looking for it on mysql but was able 
to find. Looks like I didn't try hard. :)


-afan


Dan Buettner wrote:

Afan, you'll need to have a date and time column in the database storing a
created at value, that is set on INSERT and then not changed.

Assuming you have such a column - let's call it created_at - you can run
queries like this:

/* to get count of records created on Mondays */
SELECT COUNT(*)
FROM table t
WHERE DAYOFWEEK(t.created_at) = 2;

/* to get count created on a given date between 8 AM and 4 PM */
SELECT COUNT(*)
FROM table t
WHERE t.created_at = 2007-11-20 8:00
AND t.created_at = 2007-11-20 16:00;

MySQL's docs on date and time functions are here:
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html

HTH,
Dan




On Nov 20, 2007 12:16 PM, Afan Pasalic [EMAIL PROTECTED] wrote:


Hi,
I have to build a report - when (date and/or time) the records are
inserted. E.g., number of records inserted on Monday - doesn't matter
what month.
Or, number of records inserted on specific date between 8am and 4pm.

Thanks for any help.

-afan


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]






--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]