Karuppiah RK
Karuppiah RK

Reputation: 3964

convert bigint to number of days

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

MY OUTPUT

enter image description here

I want to show the expiry date in number of days. eg: Expired in 69 days. how to convert bigint to number of days?

Upvotes: 0

Views: 458

Answers (1)

Andrzej Reduta
Andrzej Reduta

Reputation: 767

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

Upvotes: 1

Related Questions