Function DATE_TRUNC in Snowflake (Docs here) allows you to truncate a given timestamp to a given default unit of time, being available:
'YEAR', 'MONTH', 'DAY', 'HOUR', 'MINUTE' and 'SECOND'
As an example:
DATE_TRUNC('MINUTE', '2015-05-08T23:39:35.123') --> 2015-05-08T23:39:00.000'
How would we do it if we want to truncate a date to a customize unit of time as in:
'5 MINUTE' OR '30 SECONDS'
As an example these customized times would give:
DATE_TRUNC('30 SECONDS', '2015-05-08T23:39:35.123') --> 2015-05-08T23:39:30.000'
DATE_TRUNC('30 SECONDS', '2015-05-08T23:39:15.123') --> 2015-05-08T23:39:00.000'
DATE_TRUNC('5 MINUTES', '2015-05-08T23:39:35.123') --> 2015-05-08T23:35:00.000'
DATE_TRUNC('5 MINUTES', '2015-05-08T23:34:35.123') --> 2015-05-08T23:30:00.000'
Is there a workaround or alternative function to get these results?
Thanks
