Monday, January 24, 2011

Menghitung Interval Waktu dan Hari dari Awal Registrasi di MySQL

SELECT
tgl_masuk AS 'Tgl Masuk',NOW(),
DATEDIFF(NOW(), tgl_masuk) AS hari,
TIMEDIFF(NOW(), tgl_masuk) AS waktu,
FROM user;

Hasilnya Kira-kira seperti ini:

|-----Tgl Masuk-------|--------NOW()--------|-hari-|--waktu--|
|1/24/2011 7:00:00 AM |1/24/2011 9:37:29 AM | 0 |02:37:29 |

1 comment:

ah said...

Sangat membantu, thanks