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 6989855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:16:06+00:00 2026-05-27T19:16:06+00:00

Well, I need get two values that represents the distance between two full dates-only

  • 0

Well, I need get two values that represents the distance between two full dates-only (no hour/time)… On MySQL we have PERIOD_DIFF that get the diff between two dates (only month and year), but I need to include the day too.

I have two dates like:

  • 2011-12-05 and 2012-01-10. After 2012-01-05 I have 1 full month, more 5 days.
  • 2012-01-01 and 2012-03-01. I have 2 months and 0 day.
  • 2012-02-29 and 2012-03-28¹. I have 0 month and 28 days. More: for 1 month, I need 2012-03-29.
  • 2013-01-29 and 2013-02-28². I have 0 month and 30 days. More: for 1 month, I need 2013-03-01, because 2013-02-29 not exists.
  • 2013-03-31 and 2013-04-30. Fix: really I have 0 month and 30 days. More: for 1 month, I need 2013-05-01, because 2013-04-31 not exists.

¹ 2012 is a leap year / bissexto;
² 2013 is not;

I don’t know what I need do exactly to solve that.

  • 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-27T19:16:06+00:00Added an answer on May 27, 2026 at 7:16 pm

    Set some variable for total difference in months to 0.

    Use DATEDIFF to get the total difference in days between your start and end date.

    For each month between your start and end month (if there are any months in between), use LAST_DAY and DATEDIFF to calculate the number of days for that month.

    Subtract the number of days for that month from the total difference in days, and add 1 to the total difference in months.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a JavaScript library that supports Ajax as well as help me in
I have a query where I need to get post + every tag that
I have a function that expects two cutoff values, called min_df and max_df .
Im trying to do a left join on two tables to get all values
Well i need to make it so any user can have a foo.com/username in
Well i need some help here i don't know how to solve this problem.
I understand very well the need for websites' front ends to be coded and
I'm a beginner in ruby and in programming as well and need help with
Well behaved windows programs need to allow users to save their work when they
I need to embed an entire well-formed xml document within another xml document. However,

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.