Sometime it is required to convert a datatype of a column to TIMESTAMP(0) which is stored as TIMESTAMP(6). By default,TIMESTAMP(6) stores microseconds. Lets try to achieve this with the help of CURRENT_TIMESTAMP keyword which by default stores current data/time along with microseconds and timezone.
Example: Sample query for current timestamp showing microseconds and timezone
SELECT CURRENT_TIMESTAMP;
Output: 2017-01-19 11:43:44.310000+00:00
SELECT CAST(CURRENT_TIMESTAMP as TIMESTAMP(0));
Output: *** Failure 7454 DateTime field overflow.
SELECT CAST(CAST(CURRENT_TIMESTAMP AS VARCHAR(19)) AS TIMESTAMP(0));
Output: 2017-01-19 11:44:28
SELECT CAST(CAST( CURRENT_TIMESTAMP AS DATE) AS TIMESTAMP(0)) + (CAST(CURRENT_TIMESTAMP AS TIME(6)) - TIME '00:00:00' HOUR TO SECOND);
Output: 2017-01-19 11:45:18