>>  > I'm trying to figure out how to select records from an events
>>>  database which (from today) will take place on next weekend. The
>>>  table has a from_date and a to_date fields, among other. I've found a
>>>  way mixing PHP with SQL, but I'm curious to know if is there a neat
>>>  and pure SQL version using the built-in date functions in mySQL.
>>
>>Can you explain differently or give some more detail?  Perhaps show some
>>actual table data, show what output you want, state explicitly in words what
>>you want to accomplish and explain what the problem is.  I'm sure I (and any
>>number of others can help), but I don't understand the problem based on what
>>you've written.
>
>Sorry, I'll try to explain better. I want to develop a php/mysql 
>based agenda of city activities, and these are stored in a table 
>with id,type,title,description and from_date and to_date fields. A 
>pseudo query which would retrieve what I need would be:
>
>select * from city_agenda where from_date<='next_sunday' and 
>to_date>='next_saturday';
>
>But I do not see how to get 'nex_saturday' and 'next_sunday' using 
>mySQL  date functions. With PHP is easy to find out these dates and 
>pass them to the select, but I wonder if is there a pure SQL version 
>of this.
>
>Anyone?
>
>TIA
>
>Llorenc Sole
>Maresme Netcom, S.L.

Sir, the following retrieves the date for the Sunday of the current 
week that runs from Sunday to Saturday. Use Data_add() to add 7 and 
13 days for next Sunday and the following Saturday.
    SELECT  Date_sub(
                     Now(),
                     Interval If(Weekday(Now()) = 6, 0, Weekday(Now()) +
                     1) day
            )

Bob Hall

Know thyself? Absurd direction!
Bubbles bear no introspection.     -Khushhal Khan Khatak

---------------------------------------------------------------------
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