Weeblesue Posted November 28, 2010 Share Posted November 28, 2010 I have a php script that pulls names and dates from my database. the trouble is, it's a genealogy database so BirthMonth, BirthDate, and BirthYear are separate columns (integers). I can't use Date or Year because years before 1900 are not recognized as valid. I'd like to see results like: Bob Smith 11 27 1810 Jim Davis 11 29 1965 David Jones 12 2 1919 Jane Doe 12 3 2009 Mary Smith 12 10 1845 Obviously the year is just an integer value; no math is done on it. Any advice? I really run into trouble when the selection runs into the next month - like today (11/27) through 12/11. Many thanks in advance, Weeble Quote Link to comment https://forums.phpfreaks.com/topic/220039-need-to-pull-records-today-plus-14-days-using-monthday-only/ Share on other sites More sharing options...
yungbloodreborn Posted November 28, 2010 Share Posted November 28, 2010 Weeblesue, If you can translate that from month/date to dayofyear, you will almost have it solved. For a rough translation, you could use ((month - 1) * 30) + day. That would remove months from the problem, then the only problem would be dec17-dec31 overlapping into jan. I don't have the last piece of the answer, but hopefully that helps somewhat. -YB Quote Link to comment https://forums.phpfreaks.com/topic/220039-need-to-pull-records-today-plus-14-days-using-monthday-only/#findComment-1140512 Share on other sites More sharing options...
Pikachu2000 Posted November 28, 2010 Share Posted November 28, 2010 Why not store it as a properly formatted date, in a DATE field type in the database? That would give you a valid date range of 1000-01-01 through 9999-12-31 Quote Link to comment https://forums.phpfreaks.com/topic/220039-need-to-pull-records-today-plus-14-days-using-monthday-only/#findComment-1140520 Share on other sites More sharing options...
Pikachu2000 Posted November 28, 2010 Share Posted November 28, 2010 If you decide to go that route, you can add another field as a DATE field, then go through the table all at once and insert the date from the current fields. UPDATE `table` SET `new_date_field` = (SELECT CONCAT_WS('-', `old_year`, `old_month`, `old_day`)) Quote Link to comment https://forums.phpfreaks.com/topic/220039-need-to-pull-records-today-plus-14-days-using-monthday-only/#findComment-1140527 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.