SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    657
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mysql week from Monday till Sunday

    Hi,

    I created a query to get the date for the week, but now I noticed that the date was from Sunday to Monday.
    How can I start it from Monday to Sunday.

    Here is my query:

    Code:
    SELECT DISTINCT r.report_date, r.process_id
        FROM op_reports AS r 
        JOIN shift_list AS s ON (s.shift_id = r.report_shift)
        JOIN process_list AS p ON (p.process_id = r.process_id)
        WHERE WEEK(report_date) = '30'
        GROUP BY r.report_date ORDER BY r.report_date  ASC;
    Thank you so much.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,015
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by newphpcoder View Post
    How can I start it from Monday to Sunday.
    please go to the manual and look up the WEEK() function
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    657
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks

    I resolved it now using this query:

    SELECT DISTINCT r.report_date, r.process_id
    FROM op_reports AS r
    JOIN shift_list AS s ON (s.shift_id = r.report_shift)
    JOIN process_list AS p ON (p.process_id = r.process_id)
    WHERE WEEK(report_date, 1) = '30'
    GROUP BY r.report_date ORDER BY r.report_date ASC;


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
  •