Drewdle Posted January 23, 2011 Share Posted January 23, 2011 Is there a way to add a date of birth into a mysql but display it as the age?... e.g Mysql = 04/06/89 Display = 21 Quote Link to comment https://forums.phpfreaks.com/topic/225359-date-of-birth/ Share on other sites More sharing options...
Pikachu2000 Posted January 23, 2011 Share Posted January 23, 2011 Yup. SELECT ((DATE_FORMAT(NOW(),'%Y') - DATE_FORMAT( `dob_field`, '%Y')) - (DATE_FORMAT(NOW(), '00-%m-%d') < DATE_FORMAT( `dob_field`, '00-%m-%d'))) AS age FROM `table_name` Quote Link to comment https://forums.phpfreaks.com/topic/225359-date-of-birth/#findComment-1163813 Share on other sites More sharing options...
Drewdle Posted January 23, 2011 Author Share Posted January 23, 2011 I swear the help I've had on here is second to none. It seems php can do damn near anything...don't suppose you have a snippet to make it make me a cup of tea do you?...Lol. Thanks man! Quote Link to comment https://forums.phpfreaks.com/topic/225359-date-of-birth/#findComment-1163816 Share on other sites More sharing options...
QuickOldCar Posted January 23, 2011 Share Posted January 23, 2011 You know........since php can control external devices as well....I think it's very possible!!! Quote Link to comment https://forums.phpfreaks.com/topic/225359-date-of-birth/#findComment-1163818 Share on other sites More sharing options...
Drewdle Posted January 23, 2011 Author Share Posted January 23, 2011 Lol. Your thinking about it now aren't you? Giving your kettle a small hard drive, just big enough to hold a script to turn it on when you click a button on your computer?... Or something like that anyway... Quote Link to comment https://forums.phpfreaks.com/topic/225359-date-of-birth/#findComment-1163819 Share on other sites More sharing options...
Zurev Posted January 23, 2011 Share Posted January 23, 2011 I swear the help I've had on here is second to none. It seems php can do damn near anything...don't suppose you have a snippet to make it make me a cup of tea do you?...Lol. Thanks man! Well that right there is pure SQL, amazing what SQL can do by itself before it even reaches the PHP. Quote Link to comment https://forums.phpfreaks.com/topic/225359-date-of-birth/#findComment-1163822 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.