Menghitung Umur dengan Mysql

Posted: December 4, 2010 in Mysql

Sebenarnya banyak cara untuk menghitung umur, disini salah satu contoh menghitung umur di database mysql

/*** Umur ***/

DELIMITER $$

DROP FUNCTION IF EXISTS `MYSQL`.`age`$$

CREATE FUNCTION `MYSQL`.`age`(tgllahir date,tglskrg date)
RETURNS integer
  BEGIN
  RETURN FROM_DAYS(TO_DAYS(tglskrg) - TO_DAYS(tgllahir));
  END$$

DELIMITER ;

/*  select age(‘tgl lahir’,’tgl sekarang’); */

Selamat Mencoba😀

CMIIW….😀

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s