Home > Blogroll, fun, sql > Are you really 18 years old today?

Are you really 18 years old today?

February 28th, 2008 Leave a comment Go to comments

18 is a nice age here. You can vote, you can watch movie or drink Gin-tonic. You also get married and go to jail !

Are you really 18 today?


select add_months(date '1990-02-28',18*12) from dual;
ADD_MONTHS(DATE'199
-------------------
29.02.2008 00:00:00

come back tomorrow :twisted:

or check an old post of mine How old are you :D

Tags:
  1. Claudia Zeiler
    February 28th, 2008 at 19:11 | #1

    Hi Laurent,
    The person born Feb 29, 1992 acquires the day the the one born Feb 28, 1990 lost.

    1* select add_months(date ’1992-02-29′,18*12) from dual
    SQL> /

    ADD_MONTH
    ———
    28-FEB-10

    By the way, do you know “The Pirates of Penzance”? The whole plot turns around the hero who was indentured to pirates until his 21st birthday. BUT he was born Feb 29. No one ever claimed that Gilbert and Sullivan make sense. :-) )
    -Claudia

  2. February 28th, 2008 at 19:19 | #2

    Hi Claudia,
    No, I did not know the Pirates of Penzance.
    I have an uncle who is celebrating his 18th birthday tomorrow… since his father reached its 101st I would not be surprised he will reach 21st.
    :)
    Laurent

  3. February 28th, 2008 at 20:31 | #3

    nothing unexpected..

    doc:
    If date is the last day of the month or if the resulting month has fewer days than the day component of date, then the result is the last day of the resulting month.

  4. February 28th, 2008 at 20:37 | #4

    nothing unexpected if you read the doc before using add_months :D

  5. Anonymous
    February 29th, 2008 at 11:11 | #5

    If I was born Feb 28, 1990. Today is my birth day for 18 years old.

    ADD_MONTH
    ———
    27-FEB-08

    SQL> select add_months(date ’1990-02-28′,18*12) from dual;

    ADD_MONTH
    ———
    29-FEB-08

  6. February 29th, 2008 at 12:11 | #6

    OK!
    I can watch adult movie or drink Gin-tonic.

    create function add_mon (date1 IN DATE,add_mon IN NUMBER) return DATE IS loc_date2 date;

    BEGIN
    loc_date2:= ADD_MONTHS(date1-1,add_mon);

    IF LAST_DAY(date1) = date1
    THEN
    IF LAST_DAY(loc_date2)=loc_date2
    THEN
    RETURN loc_date2;
    ELSE
    RETURN loc_date2 +1;
    END IF;
    ELSE
    RETURN ADD_MONTHS(date1,add_mon);
    END IF;

    END;
    /

    SQL> l
    1 declare
    2 a date;
    3 begin
    4 a := add_mon (to_date(’1990-02-28′,’YYYY-MM-DD’),18*12);
    5 dbms_output.put_line(a);
    6* end;
    SQL> /
    28-FEB-08

  7. February 29th, 2008 at 15:07 | #7

    not sure if you can enter the party when born 29-FEB-1991 next year before 1st march… depends on the bodyguard :-)

  8. March 4th, 2008 at 14:14 | #8

    of course my comment is not very accurate… I mean if you are born 29-feb-1992 you will not be 18 on feb-28-2010 but one day later

  9. March 26th, 2008 at 10:22 | #9

    :-) :-) :-)

  10. scott burnworth
    September 26th, 2008 at 02:49 | #10

    common law provides that a person becomes 18 at 12:01 am on the day before the 18th birthday.

  11. September 26th, 2008 at 08:38 | #11

    which law? which country?

    any link to any government-hosted website?

  12. February 26th, 2010 at 06:07 | #12

    hi, i was born feb. 29 1992 and i’ll be turning 18 soon but the problem is when? will it be feb.28th because its the last day of that month or will it be march 1st? i’ve always held it on the 28th every common year beacuse i have twin brothers born 2 years before me on march 7th, so i can have my own month. i need to know governmently wise when will i be 18 but i just cant find my answer!!!!

  13. February 26th, 2010 at 10:21 | #13

    it depends on the country. In France, you would be able to vote or get elected on Feb 28.

    Did you intend to drink alcohol on that day? Get married? Commit crime? (or all three)

    Please try to look in your government websites

  1. No trackbacks yet.
*