Postgres创建时间戳(当前日期+特定时间)格式

Tos*_*shi 2 sql postgresql

我希望有一个由组成的时间戳 <[current date] + [specific time I can specify as a string]>

例如 2016-03-08 23:59:59

  • 2016-03-08 =>当前日期
  • 23:59:59 =>我可以指定

我很想做类似的事情

cast(cast( now()::timestamp(0) AS string) || '23:59:59' ) AS timestamp )

以更多的postgres方式。

kai*_*red 6

也许尝试:

CURRENT_DATE + TIME '23:59:59'
Run Code Online (Sandbox Code Playgroud)

我无权访问数据库atm,因此无法为您测试它,但是我发现下面的链接中的表9-27非常有用(我发现整个网页都非常有用)。

http://www.postgresql.org/docs/9.1/static/functions-datetime.html

  • 几乎正确。`CURRENT_DATE + TIME '23:59:59'`(没有`date`)。 (2认同)