Torkil,

> I have a database table containing log files that are written by
different individuals almost every day.
>
> So at any given time I want to be able to go through a web interface
and get a list over logs written in any given month.
>
> People writing in this log also work in different department, a field
also included in the log.
>
> Timestamps for the log is stored as datetime on the format "YYYY-MM-DD
HH:MM:SS"
>
> So I want to make the following selection:
> "Show me all log entries for department X for the given month"
>
> So how would I go about to do write this query in the easiest way,
given that I provide the year and month I want to view before the query
is made?
>
> select * from LOG_TABLE where DEPARTMENT='X' ..... ..... ..... ???

AND Timestamp-field >= CONCAT ( given-year, "-", given-month,       "-01
00:00:00" )
AND Timestamp-field <   CONCAT ( given-year, "-", given-month + 1, "-01
00:00:00" )

CONCAT() discussed in 6.3.2 String Functions

Regards,
=dn


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to