Unveiling the Distinction between 'YYYY' and 'RRRR' in Oracle SQL
In Oracle SQL, the formats 'YYYY' and 'RRRR' both appear to produce the same result when used with the trunc() function in the context of year-based truncations. However, a subtle difference exists between the two.
'YYYY': A Static Representation of the Year
The 'YYYY' format represents the year in a four-digit form, regardless of the input. This means that '27-Jul-1987' will always be truncated to '1987' using this format.
'RRRR': Contextual Year Interpretation
The 'RRRR' format, on the other hand, introduces a specific interpretation rule for years given as two digits. Specifically:
This rule ensures that dates like '27-Jul-1987' are interpreted consistently, regardless of the current century.
The above is the detailed content of What's the Difference Between `YYYY` and `RRRR` Year Formats in Oracle SQL's `TRUNC` Function?. For more information, please follow other related articles on the PHP Chinese website!