0

I have a dataset with name and date of birth of some people, and I want to calculate their age! I helped to form the query (for BigQuery) to obtain this result? thanks

1
  • Could you show us what have you tried so far? Commented Jun 10, 2013 at 14:17

1 Answer 1

1

That should be easy for BigQuery, a lot depends on how you are storing the date of birth.

Let's say it's a string, on the form '2005-10-01'. One way to get ages is:

SELECT INTEGER(
    (NOW() - (TIMESTAMP(CONCAT(birthdate, ' 00:00:00'))))
    / 24/3600/365/1000/1000)
FROM users
Sign up to request clarification or add additional context in comments.

1 Comment

How does this deal with leap years?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.