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

  • SEARCH
  • Home
  • 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 890445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:44:01+00:00 2026-05-15T13:44:01+00:00

In MySQL, I can do something like: SELECT DATE_ADD(‘2010-07-02’, INTERVAL 1 MONTH) And that

  • 0

In MySQL, I can do something like:

SELECT DATE_ADD(‘2010-07-02’, INTERVAL 1 MONTH)

And that returns:

2010-08-02

That’s great… now is there a MySQL function that I can use to find what the date would be one month in advance on the same day. For example, 7/2/2010 falls on the first Friday of July, 2010. Is there an easy way to find what the first Friday of August, 2010 is with an SQL statement?

  • 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-05-15T13:44:02+00:00Added an answer on May 15, 2026 at 1:44 pm

    It got a bit complicated, but here goes:

    SELECT IF(MONTH(DATE_ADD('2010-07-02', INTERVAL 28 DAY)) = MONTH('2010-07-02'), 
      DATE_ADD('2010-07-02', INTERVAL 35 DAY),
      DATE_ADD('2010-07-02', INTERVAL 28 DAY));
    

    Rationale: If you add 4 weeks or 5 weeks, you’re still on the same day; since all months are between 28 and 35 days long, if 4 weeks later is still the same month, add another week.

    UPDATE: Umm, I did not think this through very well – it works for first X in month, but necessarily for 2nd, 3rd… (i.e. 3rd X in month might return a 2nd X next month). Try #2:

    SELECT IF(
      CEIL(DAY(DATE_ADD('2010-07-02', INTERVAL 35 DAY)) / 7) = CEIL(DAY('2010-07-02') / 7), 
      DATE_ADD('2010-07-02', INTERVAL 35 DAY),
      DATE_ADD('2010-07-02', INTERVAL 28 DAY));
    

    Rationale: CEIL(DAY(x) / 7) is x’s week number. If it’s different when you add 5 weeks, then add 4 weeks.

    UPDATE 2: LOL, I suck today, I should really think before I post… Week is usually defined as Mon-Sun, or Sun-Mon, not as from whatever started the month till 6 days later. To compensate for this:

    SELECT IF(
        CEIL((DAY(DATE_ADD('2010-07-02', INTERVAL 28 DAY)) - DAYOFWEEK('2010-07-02')) / 7)
        = CEIL((DAY('2010-07-02') - DAYOFWEEK('2010-07-02')) / 7), 
      DATE_ADD('2010-07-02', INTERVAL 28 DAY),
      DATE_ADD('2010-07-02', INTERVAL 35 DAY));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using MySQL , I can do something like: SELECT hobbies FROM peoples_hobbies WHERE person_id
I've learned that MySQL can compress communication between servers and clients. Compression is used
Can MySql 5.0 views use tables that are located on another server? What is
I know that with mysql you can write SQL statements into a .sql file
How can I select specific rows in a MySQL Table? So instead of select
I'm building a quick csv from a mysql table with a query like: select
I'm trying to write a sql function to do something like: SELECT person.id, person.phonenumber
SELECT count(*) c FROM full_view WHERE verified > ( DATE (NOW()) - INTERVAL 30
If I have a MySQL statement like this: $sql=SELECT `name`, DATE(`time`), FROM `students` WHERE
Date and time in MySQL can be stored as DATETIME, TIMESTAMP, and INTEGER (number

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.