Programming Blog

This blog is about technical and programming questions and there solutions. I also cover programs that were asked in various interviews, it will help you to crack the coding round of various interviews

Thursday 15 March 2018

Age calculator

I have created the age calculator using PLSQL,
In this user input the date of birth and the age is shown as result.

A function names age_calculator returns the age by taking the input as date of birth,you can also use procedure here.

program


declare

output number;

function age_calculator  return number 
as
age number; 
begin
select round(ceil(sysdate-to_date('&enter_DOB','dd/mm/yyyy'))/365) into age from dual;
return age;
end;

begin
  output :=age_calculator();
  dbms_output.put_line('age is :'||output);
  end;
  

No comments:

Post a Comment