There are different ways to do accomplish this.

You can use either:
SELECT id, datecol, text FROM table WHERE YEAR(datecol) = 2004 AND
MONTH(datecol) =$mySelectedMonth;

or:
SELECT id, datecol, text FROM table WHERE LEFT(datecol,7) =
'2004-$mySelectedMonth';

As of formated date... use the DATE_FORMAT function. "Monday,
10.05.2004" should be something like DATE_FORMAT(datecol, '%W
%d.%c.%Y')

Check out this page:
http://dev.mysql.com/doc/mysql/en/Date_and_time_functions.html for
more information.


----- Original Message ----- 
From: "H Bartel" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, May 10, 2004 1:56 PM
Subject: Date Question 2


> Hi again,
>
> I got the MONTH() selection thing working now, but it seems like
I'm not
> getting the hang of the concept with the sql date..
>
> With PHP and a UNIX timestamp I would just insert a timestamp, the
> select it and after selection, go ahead and manipulate it to fit
my
> needs, like extracting day names, months etc.
>
> With the sql date it seems that all manipulation with dates has to
be
> done during selection. Which would make sense somehow, since it's
a
> query language.. I'm just wondering, why I should use readable
dates, if
> it's so much harder to get where I need to, instead of sticking to
unix
> timestamps and manipulate these with PHP functions?
>
> What I want to do is:
>
> Select every row from the current month and year with:
>
> SELECT id, datecol, text FROM table WHERE MONTH(datecol)
> =$mySelectedMonth;
>
> then output the different parts of the date like: Monday,
10.05.2004
>
> or do I have to get all this within the query?
>
> Thanks for your patience and time reading this rather long post
and
> maybe offering some enlightening explanation?
>
> Regards,
> Holger
>
> -- 
> 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]

Reply via email to