Jump to content

Need to pull records today plus 14 days using Month/Day only


Weeblesue

Recommended Posts

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

 

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

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`))

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.