in postgres, can you set the default formatting for a timestamp, by session or globally?

前端 未结 3 1899
走了就别回头了
走了就别回头了 2020-12-10 05:16

In Postgres, is it possible to change the default format mask for a timestamp?

right now comes back as

2012-01-03 20:27:53.611489

I

3条回答
  •  悲&欢浪女
    2020-12-10 05:55

    to_char() is used to create a string literal. If you want a different timestamp value, use:

    date_trunc('minute', now())
    

    For an input mask you can use:

    to_timestamp('2012-01-03 20:27:53.611489', 'YYYY-MM-DD HH24:MI')
    

    Cast to timestamp without time zone by appending ::timestamp.

    To my knowledge, there is not setting in PostgreSQL that would trim seconds from timestamp literals by default.

提交回复
热议问题