user3119023
user3119023

Reputation: 1

Last dateof month using pl/sql

I want to write a programm using PL/SQL

If the date of birth of one person is 12th May 1978, so that the person retirement date should be 12th may 2038, but instead of 12th may 2038 the date of retirement of that person will be the last date of the same month (it will automatically redirect the last day of the same month).

Upvotes: 0

Views: 123

Answers (2)

Alex Poole
Alex Poole

Reputation: 191235

Oracle has a last_day function that does exactly that:

select sysdate, last_day(sysdate) from dual;

SYSDATE   LAST_DAY(SYSDATE)
--------- -----------------
19-DEC-13 31-DEC-13         

From PL/SQL:

declare
  month_end date;
begin
  month_end := last_day(sysdate);
end;

... but pass in your adjusted date of birth value.

Upvotes: 4

vkamayiannis
vkamayiannis

Reputation: 735

Check function last_day e.g.

select last_day(to_date('12/05/2038', 'dd/mm/yyyy')) from dual

Upvotes: 4

Related Questions