TRUNC SQL Function: Truncate Numbers & Dates
The TRUNC() function in SQL is typically used to remove the decimal part of a number or date value. Its effect depends on the context.
- The TRUNC() function in Excel can remove the decimal part of a number and return an integer value. For example, TRUNC(3.14159) will return 3.
- For date values: The TRUNC() function can truncate a date value to a specified granularity, such as year, month, or day. This means it will remove the time part of the date and only keep the date part at the specified granularity. For example, TRUNC(SYSDATE, ‘MM’) will return the first day of the month for the current date.
Please note that the exact behavior of the TRUNC() function may vary depending on the database management system, so it is advisable to refer to the documentation of the respective database to understand the specific usage and supported options of the TRUNC() function in that database.