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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:49:44+00:00 2026-06-18T09:49:44+00:00

So this question seems to be asked in various forms in programming classes. I’ve

  • 0

So this question seems to be asked in various forms in programming classes. I’ve seen this asked with triggers, functions, and such. I’ve calculated the leap year part of the program, and there are a couple of different ways to calculate age from your birthday, whether dividing by 365.25 or intervals months between and probably a couple of other ways to go about this the best way.

I’m just having some problems with my Age calculation and am getting information overload on doing this in other programs and specifically programming this in PL/SQL for Oracle Dev.

This one shows how it’s done in SQL SERVER: calculating age from sysdate and birthdate using SQL Server

This one uses triggers and it is similar but not quite what I’m looking for. Calculating age from birthday with oracle plsql trigger and insert the age in table

Write a PL/SQL block to accept your birthdate. Calculates and prints
your age in years including one decimal point. Also checks whether
your birth year is a leap year or not. Print a message like “My
birth year is a leap year.” or “My birth year is not a leap
year.” Hint: To determine the leap year, the year should be exactly
divisible by 4 but not divisible by 100, or it should be
divisible by 400.

SET SERVEROUTPUT ON
DECLARE
   v_birthday_year        NUMBER(4)    := &v_birthday_year;
   v_your_age             NUMBER(4, 1);
   v_leap_remainder1      NUMBER(5, 2);
   v_leap_remainder2      NUMBER(5, 2);
   v_leap_remainder3      NUMBER(5, 2);

 BEGIN
   v_leap_remainder1 := MOD(v_birthday_year, 4);
   v_leap_remainder2 := MOD(v_birthday_year, 100);
   v_leap_remainder3 := MOD(v_birthday_year, 400);

 IF ((v_leap_remainder1 = 0 AND v_leap_remainder2 <> 0 ) 
     OR v_leap_remainder3 = 0) 
 THEN
   DBMS_OUTPUT.PUT_LINE(v_birthday_year || ' is a leap year');

 ELSE
   DBMS_OUTPUT.PUT_LINE (v_birthday_year || ' is not a leap
   year');

  END IF;


  TO_CHAR(SYSDATE, 'DD-MM-YYYY')
  v_your_age := (MONTHS_BETWEEN(TRUNC(SYSDATE), v_birthday_year)/12);
  DBMS_OUTPUT.PUT_LINE ('Your age is ' || v_your_age);

 END;
 /

Actually I figured it out, it was a to_date conversion for the dob, separate variables for birthyear, and dob, and age. Age calculated to 1 decimal. Trunc(x, 1) Works great now.

  • 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-18T09:49:46+00:00Added an answer on June 18, 2026 at 9:49 am

    You can also try to check it with conversions to Julian dates. When you convert a timestamp to a Julian date you get the number of days since some date before -4000 BC. If you calculate the difference between two dates you know the number of days between those dates. So do it for January 1st and December 31st of you birth year and you’ll know if it was leap year or not.

    For calculating age check the function months_between (check the last answer for this question).

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

Sidebar

Related Questions

This question seems to have been asked a lot, but I haven't seen an
I've seen this question asked on here, but it seems to be different than
This question has been asked several times in various forms but I haven't found
So various iterations of this question seems to have been asked on this site
I've seen this question asked before but it seems that the answer may be
This question has been asked in various forms on here before, but I cannot
This question seems to be asked freqeuently over the internet but I still can't
I have asked this question ever before and it seems I didn't 100% resolved
Note: I've asked this question in a similiar format on superuser but it seems
It seems this type of question has been asked and answered a number of

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.