PostgreSQL でタイムスタンプを文字列として取り出したい
char にキャストするときに長さをつける
now() の場合
select now()::char(30);
実行結果
sample> select now()::char(30); +--------------------------------+ | now | |--------------------------------| | 2019-09-13 15:27:51.427441+00 | +--------------------------------+ SELECT 1 Time: 0.086s
current_timestamp の場合
select current_timestamp::char(29)
実行結果
sample> select current_timestamp::char(29) +-------------------------------+ | now | |-------------------------------| | 2019-09-13 15:29:01.630241+00 | +-------------------------------+ SELECT 1 Time: 0.067s sample>
あんまり美しいやり方ではないけれど