SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Mar 2004
    Location
    Canada
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    help with : equal to or less than

    Hi I am trying to get the data to display that equals the current week and year and past weeks. I am able to display the current week/year's data but not past or future.

    $sql="SELECT * FROM sign WHERE WEEK(DATE)=WEEK(NOW()) AND YEAR(DATE)=YEAR(NOW())";

    this is my sql statement I tried putting the >= and <= just incase I was confused but no luck.

    any ideas?

    thanks

  2. #2
    SitePoint Guru
    Join Date
    Jan 2004
    Location
    Uppsala, sverige
    Posts
    700
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Past and current records

    Code:
    SELECT * 
    FROM sign 
    WHERE ( WEEK(DATE) <= WEEK(NOW()) AND YEAR(DATE)=YEAR(NOW()))
      or year(date) < year(now())
    Future records

    Code:
    SELECT * 
    FROM sign 
    WHERE ( WEEK(DATE) > WEEK(NOW()) AND YEAR(DATE)=YEAR(NOW()))
      or year(date) >= year(now())
    Why not

    Code:
    select * from sign where date <= current_date
    ?

  3. #3
    SitePoint Member
    Join Date
    Mar 2004
    Location
    Canada
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    thanks

    Ill try these after work, select from current date alone wont work because I want the data to appear for the whole week not just the day.


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
  •