Calculate age of a person and compare it

how can i calculate the age of a person using database " birth date"

my teble is user and column is bday …
now i want to calculate the age will some one please tell me how can i
calculate the age…

actually i want to compare my two database fields birthdate and
joining date …that is why i need this…

will someone please tell me how can i do that

abhi wrote:

how can i calculate the age of a person using database " birth date"

my teble is user and column is bday …
now i want to calculate the age will some one please tell me how can i
calculate the age…

actually i want to compare my two database fields birthdate and
joining date …that is why i need this…

will someone please tell me how can i do that

Does this help?

def age(dob)
now = Time.now

how many years?

has their birthday occured this year yet?

subtract 1 if so, 0 if not

age = now.year - dob.year - (dob.to_time.change(:year => now.year) >
now ? 1 : 0)
end