SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Dec 2000
    Location
    Norcross, GA
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    According to MySQL documentation, I can pull the prior weeks events by using the following query:

    Code:
    SELECT something FROM table WHERE TO_DAYS(NOW()) - TO_DAYS(date_col) <= 7;
    No problem, works like a charm. However, let's take it to the next level.

    Say I want to only display events from Monday-Friday - for example (Psuedocode):

    Code:
    SELECT something FROM table WHERE today -(minus) Monday
    So that if it were Thursday, it would return the current day plus the three previous. Or if it were Tuesday it would return only Tuesday and Monday.

    Is there a way to fanaggle the query to make this possible?

    Thanks, Mike

  2. #2
    SitePoint Zealot
    Join Date
    May 2000
    Posts
    150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Would this work?

    $wday = ((localtime(time)) [6]) - 1;
    Get offset from Monday, perl code

    CONDITION: 'date_col' between TO_DAYS(NOW()) AND (TO_DAYS(NOW()) - $wday)

  3. #3
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That may work arpith but here it is MySQL query format

    SELECT something from tablename WHERE DATE_SUB(CURDATE(), INTERVAL WEEKDAY(CURDATE()) DAY) < datefield;
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •