2014-04-19 54 views
0
SELECT FROM_UNIXTIME(date_of_registration, '%Y-%m-%d %H:%i:%s') AS user_registeredon, 
      FROM_UNIXTIME(renewal_date, '%Y-%m-%d %H:%i:%s') AS expiry_date, 
      a.agent_id 
    FROM ta_agent a, 
      ta_subscription s 
    WHERE s.agent_id = a.agent_id 

我的輸出轉換BIGINT的天數

enter image description here

我要顯示的天數到期日。例如:69天內過期。如何將bigint轉換爲天數?

回答

1
SELECT FROM_UNIXTIME(date_of_registration, '%Y-%m-%d %H:%i:%s') AS user_registeredon, 
     ROUND((renewal_date - date_of_registration)/(60*60*24)) AS expiry_date, 
     a.agent_id 
FROM ta_agent a, 
     ta_subscription s 
WHERE s.agent_id = a.agent_id 
+0

秒*分鐘*小時。 Unix時間存儲爲從UNIX開始的秒數epoche(01.01.1970) –