Let us understand how to use trunc on dates or timestamps and get beginning date of the period.
- We can use MM to get beginning date of the month.
- YY can be used to get begining date of the year.
- We can apply trunc either on date or timestamp, however we cannot apply it other than month or year (such an hour or day).
DESCRIBE FUNCTION trunc; SELECT trunc(current_date, 'MM'); SELECT trunc('2019-01-23', 'MM'); SELECT trunc(current_date, 'YY'); SELECT trunc(current_timestamp, 'HH'); // will not work