How to Round Timestamps in Redshift

Rounding/truncating timestamps are especially useful when you're grouping by time. The Redshift function you need here is TO_CHAR():

select to_char(sysdate, 'YYYY-MM-DD HH24:MI');

Truncating to date or year is easier because you can just use the TRUNC() and EXTRACT() functions, respectively:

select trunc(sysdate);
select extract(year from sysdate);
database icon
Real-time SQL collaboration is here
Get started with PopSQL and Redshift in minutes