5

Amazon Redshift では、現在のタイムスタンプを 0 秒に変換しようとしています。それはこれからです:

2013-12-17 12:27:50

これに:

2013-12-17 12:27:00

私は次のことを試しました:

SELECT dateadd(second, -(date_part(second, getdate())), getdate());
ERROR:  function pg_catalog.date_add("unknown", double precision, timestamp without time zone) does not exist
HINT:  No function matches the given name and argument types. You may need to add explicit type casts.

SELECT dateadd(second, -cast(date_part(second, getdate()) as double precision), getdate());
ERROR:  function pg_catalog.date_add("unknown", double precision, timestamp without time zone) does not exist
HINT:  No function matches the given name and argument types. You may need to add explicit type casts.

SELECT getdate() - date_part(second, getdate());
ERROR:  operator does not exist: timestamp without time zone - double precision
HINT:  No operator matches the given name and argument type(s). You may need to add explicit type casts.

私はおそらくこれを行うための非常に簡単な方法を見逃しています! 誰か提案はありますか?

4

3 に答える 3

7

date_trunc()functionを使用するのが最も簡単ですが、それは選択している間のみ機能します:

SELECT date_trunc('minute', TIMESTAMP '2013-12-17 12:27:00');

Redshift DB にデータをロードする前にデータを前処理するか、中間テーブルを使用してからINSERT INTO...SELECTステートメントを使用できます。

INSERT INTO destination_table (
    SELECT date_trunc('minute', date_column), other_columns_here    
    FROM source_table
);
于 2013-12-17T13:49:28.457 に答える
0

date_trunc() をチェック

SELECT date_trunc('minute', TIMESTAMP '2013-12-17 12:27:00');
于 2013-12-17T12:51:44.900 に答える
-1

次のように日付をフォーマットできます。

select to_char(now(), 'YYYY-MM-DD HH24:MI:00');
于 2013-12-17T12:47:36.137 に答える