Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8809941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:59:59+00:00 2026-06-14T02:59:59+00:00

In my PHP code I’m using date(N) ISO-8601 numeric representation of the day of

  • 0

In my PHP code I’m using date(“N”) ISO-8601 numeric representation of the day of the week 1 (for Monday) through 7 (for Sunday).

Now when I wanted to make a query to search for a specific date.

I found that in MySQL:

  • The date_format using %w will return (0=Sunday..6=Saturday)

  • The DAYOFWEEK(date) will return (1 = Sunday .. 7=Saturday)

Is there a fast way to fix this issue without doing some PHP ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T03:00:00+00:00Added an answer on June 14, 2026 at 3:00 am

    Trying to match…

    PHP date('N'):
    
    Mon Tue Wed Thu Fri Sat Sun
    1   2   3   4   5   6   7

    To one of these…

    MySQL DATE_FORMAT(col, '%w'):
    
    Mon Tue Wed Thu Fri Sat Sun
    1   2   3   4   5   6   0
    
    MySQL DAYOFWEEK(col):
    
    Mon Tue Wed Thu Fri Sat Sun
    2   3   4   5   6   7   1
    

    I would use a CASE statement with DATE_FORMAT as you only have to worry about Sunday.

    SELECT
        CASE
            WHEN DATE_FORMAT(col, '%w') = 0
                THEN 7
            ELSE DATE_FORMAT(col, '%w')
       END AS dayofweek
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This php code is called through ajax from javascript and should return a numeric
PHP code: echo date(c); //out put like this 2012-06-19T20:37:44+05:30 echo date(d M, Y); //out
My PHP code is split between many files, and often I find myself using
I have some PHP code that I'm using to send a form off to
I'm using below PHP code here to create a particular folder if it didn't
The PHP code won't delete item from database using $noteid. If I put a
PHP CODE $t = strtotime( '2012-09-21T03:00:00+00:00 America/Chicago' ); $t2 = date('c',$t); echo $t2; OUPUT
I am using following PHP code to connect to MS Access database: $odb_conn =
I'm using this php code. but it's giving error Deprecated: Function eregi() is deprecated
PHP code: <a id=a$id onclick=check($id,1) href=javascript:void(0) class=black>Qualify</a> I want to remove the onclick=check($id,1) so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.