0

I have a table called person, how do i get a person age according to the current system time in NLS_DATE_FORMAT?

ALTER SESSION SET NLS_DATE_FORMAT = 'DD.MM.YYYY';

CREATE TABLE person (
  person_id      NUMBER (9),
  birthday       DATE CONSTRAINT nn_person_birthday NOT NULL,
  ...
);

Note: I just want the exact age, not months neither days. Example Age: 43

Note2: I insert birthday like this in my table: TO_DATE('17.05.2003','DD.MM.YYYY')

Andre Proenza
  • 149
  • 1
  • 10

1 Answers1

1

The date format doesn't matter. I would suggest:

floor(months_between(sysdate, p.birthday) / 12)
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786