Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgres create timestamp ( current date + specific time ) format

Tags:

sql

postgresql

I'd love to have timestamp which composed of <[current date] + [specific time I can specify as a string]>.

Ex. 2016-03-08 23:59:59

  • 2016-03-08 => current date
  • 23:59:59 => I can specify

I'd love to do something like

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

in more postgres way.

like image 712
Toshi Avatar asked Sep 03 '25 01:09

Toshi


1 Answers

Maybe try:

CURRENT_DATE + TIME '23:59:59'

I don't have access to a database atm so I can't test it out for you but I find Table 9-27 in the link below to be very useful (I find that whole webpage to be very useful).

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

like image 147
kaisquared Avatar answered Sep 04 '25 21:09

kaisquared