Tuesday, June 2, 2020

PostgreSQL: Get the TimeStamp of today, yesterday, tomorrow, and a number of days ago or later

To get the current timestamp:

       select current_timestamp;
       or
       select now();

To get the timestamp of the beginning of today:

       select current_date::timestamp;
       or
       select 'today'::timestamp;

To get the timestamps of yesterday and tomorrow:

      select 'yesterday':timestamp, 'tomorrow'::timestamp;
      or
      select (current_date - INTERVAL '1 day')::timestamp, (now0 + INTERVAL '1 day')::timestamp;

To get the timestamps of n days ago:

      select (current_date - INTERVAL 'n day')::timestamp;

To get the timestamp of m days later:

      select (current_date + INTERVAL 'm day')::timestamp;
      select (current_date + INTERVAL '1 month - 3 day')::timestamp
 
Also, see PostgreSQL: Get the TimeStamp of the beginning of a year, a month, or a day

-----------------------------------------------------------------------------------------------------------------
Watch the blessing and loving online channel: SupremeMasterTV live




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 for free here.

No comments:

Post a Comment