Friday, April 29, 2016

PostgreSQL: convert between date and epoch

1. Convert current time to epoch:

      SELECT extract(epoch FROM now());

      The following will give you the part before the decimal point.

      SELECT round(extract(epoch FROM now()));
      SELECT extract (epoch FROM current_date);

2. Convert a particular date to epoch:

      SELECT extract (epoch from timestamp '2016-02-28');

      SELECT extract (epoch from timestamp '2016-02-28 14:30:00');

3. Convert epoch to date:

      SELECT to_timestamp(1461888000);

-------------------------------------------------------------------------------------------

                        
If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book free here.

No comments:

Post a Comment