Age to birth year

Discussion in 'Ruby' started by eggie5, Sep 25, 2007.

  1. eggie5

    eggie5 Guest

    Given the string "18" which is the age of a person, how can I get the
    year of birth?
     
    eggie5, Sep 25, 2007
    #1
    1. Advertising

  2. eggie5 schrieb:
    > Given the string "18" which is the age of a person, how can I get the
    > year of birth?

    Time.now.year - 18

    Regards
    Jan
     
    Jan Friedrich, Sep 25, 2007
    #2
    1. Advertising

  3. eggie5 schrieb:
    > Given the string "18" which is the age of a person, how can I get the
    > year of birth?

    Time.now.year - '18'.to_i

    But this is only an approximation. ;)

    Regards
    Jan
     
    Jan Friedrich, Sep 25, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TJS
    Replies:
    9
    Views:
    16,235
    gosborne
    Sep 7, 2010
  2. =?iso-8859-1?B?bW9vcJk=?=
    Replies:
    7
    Views:
    877
    Roedy Green
    Jan 2, 2006
  3. cylin
    Replies:
    6
    Views:
    593
    Mike Wahler
    Aug 19, 2003
  4. Rick North

    Birth date for VHDL 87 ?

    Rick North, Jan 19, 2007, in forum: VHDL
    Replies:
    2
    Views:
    445
    Rick North
    Jan 20, 2007
  5. Gav

    Finding Age from Date of Birth

    Gav, Jan 4, 2004, in forum: ASP General
    Replies:
    20
    Views:
    418
    Guest
    Jan 5, 2004
Loading...

Share This Page