Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7689849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:15:36+00:00 2026-05-31T20:15:36+00:00

How should I store Birthdate’s in MySQL so that I can easily update everyone’s

  • 0

How should I store Birthdate’s in MySQL so that I can easily update everyone’s Age on a daily basis via a Cron Job?

Does it even make sense to store the Age AND the Birthdate so that when searches involving the Age are made, I don’t have to calculate each Age on-the-fly and waste CPU resources?

If so, how should I 1) store the Birthdate, and 2) calculate the Age each day?

I can imagine the daily cron script first filtering out the user’s whose Birthdate month is not the current month, then filtering out the user’s whose Birthdate day is not the current day, and then incrementing by one the age of each user that is left.

Does this make sense? If so, how would I do that? Is there a better way to do all of this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T20:15:37+00:00Added an answer on May 31, 2026 at 8:15 pm

    The simple answer is don’t; never store a persons age. It changes for each person yearly but, as you say, you have to check that it’s correct for every person daily.

    Only store the date of birth, and then calculate the age when selecting from the database. It’s only today - date of birth so takes almost no CPUs at all.

    EDIT:

    To expand upon my comment in ManseUK’s answer there’s also the possibility of failure. What happens if your server / database is down? Or your update fails to run at its specified time? Or someone comes along and runs it manually after the update already been run for that date? Or someone turns off your scheduler? There’s no danger of this happening if you calculate Age as you select from the database.

    To select where age is between 25 and 30 years and assuming a DATE column dateofbirth your query would be something like:

    select *
      from users
     where dateofbirth between date_add( curdate(), interval -30 year )
                           and date_add( curdate(), interval -25 year )
    

    Ensure users is indexed on dateofbirth.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I learnt that I should Store UTC and Show in local time. How can
I've read that I should store an ObjectContext in HttpContext.Current in order to share
I am writing a web page that should store persistent data. In IE, I
I have a mysql database table that will store locations for buildings and events
I have a table in my Android app that only should store the 50
I have a database defined with charset utf8_general_ci and a table that should store
I'm trying to create a field in a model, that should store an image
i wanted to know where we should store the db in our project and
We had a meeting this morning about how would should store our ID for
I'm working on a project of which I should store constant multi dimensional arrays.I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.