Investigating the TRUNC function
The TRUNC
function, for dealing with DATE
type values, removes all parts with smaller granularity than defined. It consists of one obligatory and one optional parameter. The first one is the DATE
attribute value (date_val
), while the second reflects the granularity (format
). If the second parameter is not defined, the default value for the day is used (the time element value will be 00 in that case). Thus, smaller granularity values (day, hours, minutes, and seconds) are removed if the second parameter defines a month. The second parameter value can be DD
, MM
, YY
, HH
, or MI
. The format unit (the second parameter) can also be Q
(quarter), W
(week of the month), or WW
(week in the year). The syntax of the function is stated in the following code block:
TRUNC(<date_val>, [<format>])
Let’s assume this is the actual time to be set by this value:
The following code shows examples of the TRUNC
function’...