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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:36:05+00:00 2026-05-14T16:36:05+00:00

How to determine the difference among dates of birth? +———-+———-+————+ | id | name

  • 0

How to determine the difference among dates of birth?

  1. +———-+———-+————+
  2. | id | name | birth |
  3. +———-+———-+————+
  4. | 00001 | Claws | 2010-04-17 |
  5. | 00002 | Claws | 2010-01-31 |
  6. | 00003 | Claws | 2009-11-31 |
  7. | 00004 | Claws | 2009-09-31 |
  8. | 00005 | Claws | 2009-07-31 |
  9. | 00006 | Claws | 2008-10-31 |
  10. +———-+———-+————+

I would like to obtain this:

+----------+----------+------------+------------------------------------------+
  1. | id | name | birth |
    diff |
  2. +———-+———-+————+——————————————+
  3. | 00001 | Claws | 2010-04-17 |
    diff (id1-id2) = 2010-01-31 –
    2010-04-17 |
  4. | 00002 | Claws | 2010-01-31 |
    diff (id2-id3) = 2010-01-31 –
    2009-11-31 |
  5. | 00003 | Claws | 2009-11-31 |
    diff (id3-id4) = 2010-01-31 –
    2009-09-31 |

If possible, ORDER BY diff DESC

Thank you for helping

Vera

  • 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-14T16:36:06+00:00Added an answer on May 14, 2026 at 4:36 pm

    It looks like you’ll want to use the datediff function, which returns the difference between two dates in days. Apply the abs function, if you want the difference to always be positive.

    Also, it looks like you want to join the table to itself to get the row related to the current one (relation defined as related_row.id = row.id+1).

    Without further knowledge of what the table definition is, or exactly how you want the differences displayed, a sample query might look like below.

    select 
       t.id, 
       t.name, 
       t.birth, 
       abs(datediff(t.birth,t2.birth)) as diff 
    from table t
    inner join table t2 on (t.id+1) = t2.id
    order by abs(datediff(t.birth,t2.birth)) desc
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for a way to determine the difference between two dates. A normal
I'm trying to determine how to calculate the difference between successive table cells in
Are there any ways to determine what the differences in databases are that affect
To determine the exact number of lines in a file I currently use: if(exec(wc
Problem: Determine which radio button was sent based on their order and submit the
To determine the file type of an attached file, I used the OS file
How do I determine the dimensionality of a list programmatically? Thanks.
I'm trying to determine if the current system is 32 or 64 bit. And
How can I determine the absolute path of a file or directory from a
I am trying to determine if a phone is located in this polygon using

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.