将bigint转换为天数

时间:2014-04-19 07:23:55

标签: mysql sql days bigint

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

我的输出

enter image description here

我想以天数显示到期日。例如:69天过期。如何将bigint转换为天数?

1 个答案:

答案 0 :(得分: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