×

Sign in with twitter.

You can follow the user and hashtags.

Share your tips on social media.

Post relative tips.

If you have relative tips, click [Add relative tips] to post.

MySQLで誕生日から年齢を算出する

@Ogaaaan@Ogaaaan 2365 viewer 61 embed viewer embed
select TRUNCATE((date_format(CURRENT_DATE, '%Y%m%d')-date_format(birthday, '%Y%m%d'))/10000, 0) from profiles

CakePHPならVirtualFieldsで'age'などと指定しておくと便利かも。

public $virtualFields = array(
'age' => "TRUNCATE((date_format(CURRENT_DATE, '%Y%m%d')-date_format(birthday, '%Y%m%d'))/10000, 0)",
);

#cakephp

Click this to change format.

Add relative tips

Users who share this tip.

Comments