Home > Archive > PHP SQL > January 2005 > MySQL Week function
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
MySQL Week function
|
|
|
|
|
|
> I have a table with birthdates and only want the persons that have
their
> birthday in this w .
You need to ask if the person's birthday THIS YEAR falls in this w .
You are actually asking if the person's birthday in the year of their
birth fell the same number of w s after the start of the year as
today's date does for this year. This is not a useful question for the
purpose...
Substitute the current year into the person's birthdate before asking
the question:
SELECT *
FROM persons
WHERE WEEK(
CONCAT( YEAR( NOW() ),
CONCAT( "-",
CONCAT( MONTH( Birthdate ),
CONCAT( "-", DAYOFMONTH( Birthdate )
)
)
)
)
) = WEEK( NOW() )
FROM mytable
---
Steve
|
|
|
|
|