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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:52:47+00:00 2026-06-18T20:52:47+00:00

I am trying to get an age in years and months from a given

  • 0

I am trying to get an age in years and months from a given DOB. Right now, my code looks like this:

COLUMN name FORMAT A25
SELECT sNo, fName||CHR(13)||lName Name, sex, TRUNC((CURRENT_DATE - dob) / 365.24, 1) Age
FROM Staff
WHERE position IN ('Manager', 'Secretary')
ORDER BY age DESC;

And it gives me Age outputs in decimal numbers (such as 58.6) which I understand, but I am needing to convert that .6 into a month somehow.

I am thinking that my method of doing this conversion isn’t the most efficient, but I have been searching for hours for a solution, but to no avail. I’ve seen DATEDIFF, but I keep getting an invalid identifier error when trying to use it.

Any ideas?

  • 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-18T20:52:48+00:00Added an answer on June 18, 2026 at 8:52 pm

    How about something like this:

    SELECT sNo, fName||CHR(13)||lName Name, sex, 
      TRUNC((CURRENT_DATE - dob) / 365.24, 1) Age,
      TRUNC(MONTHS_BETWEEN(CURRENT_DATE, dob) / 12) YEARS,
      MOD(TRUNC(MONTHS_BETWEEN(CURRENT_DATE, dob)), 12) MONTHS
    FROM Staff
    WHERE position IN ('Manager', 'Secretary')
    ORDER BY age DESC;
    

    And here is the SQL Fiddle.

    And this should get you the days as well: http://sqlfiddle.com/#!4/f3a57/4

    SELECT sNo, fName||CHR(13)||lName Name, sex, 
      TRUNC((CURRENT_DATE - dob) / 365.24, 1) Age,
      TRUNC (MONTHS_BETWEEN (CURRENT_DATE, dob) / 12) YEARS,
      MOD (TRUNC (MONTHS_BETWEEN (CURRENT_DATE, dob)), 12) MONTHS,
      TO_DATE (CURRENT_DATE) - 
          ADD_MONTHS (dob,TRUNC (MONTHS_BETWEEN (CURRENT_DATE, dob))) DAYS
    FROM Staff
    WHERE position IN ('Manager', 'Secretary')
    ORDER BY age DESC;
    

    Good luck.

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

Sidebar

Related Questions

I've been trying to get this code to work for what feels like an
I was trying a simple piece of code, get someone's name and age and
I'm trying to get a list of names back from this - but it's
I'm trying to get objects from a multi-level JSON array. This is the an
It seems like no matter what i do, i get AG_E_PARSER_PROPERTY_NOT_FOUND when trying to
I'm trying get the visible portion of UIImage from an UIImageView . UIImageView takes
Trying to get this expression to work, can someone look at it and tell
How can I get a specific value from an object? I'm trying to get
I'm trying to get Age of Empires II (AoE2) to work on my LAN.
I'm trying to get started with South data migrations. I found this SO question:

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.