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

How would you determine the column name (e.g. AQ or BH) of the nth
I'm trying to determine how to calculate the difference between successive table cells in
I'm trying to determine the score of an entry by finding the difference between
Just for the sake of experimentation, I've been trying to determine different ways to
We've got an interesting case where we are trying to determine how different instances
I want to determine whether two different child nodes within an XML document are
What are the different ways (programmatically and otherwise) to determine what versions of .NET
On a regular winforms solutions, how do you determine to break classes into different
How do I determine the size of my array in C? That is, the
Is it possible to determine the MAC address of the originator of a remote

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.