Dhaval Mistry
Dhaval Mistry

Reputation: 634

What does RR represent in date format oracle 10g?

The older version of date format is dd-mon-yy. In that case yy represents year. But if we write 31-aug-14 in oracle 10g the full date format is 31-aug-1914.

The newer version of date is dd-mon-rr. So in that date format what does rr represent? I know that it represents 21st century but what does rr mean? Please I want to know. I asked my faculties but they also don't know.

Upvotes: 2

Views: 6226

Answers (2)

APC
APC

Reputation: 146209

RR means the programmer was too lazy (or ignorant) to use YYYY. Seriously.

The RR mask was introduced in the late nineties as a kludge for the Y2K problem. It was intended to help database programmers finagle input data, because changing screens was a lot more labour intensive. It substitutes a default century of a date entered without one. YY just substitutes the current century. However, in the last years of the last century that would often not be what was intended: in 1999 it was more likely that a two-digit year like 01 would be two years in the future (i.e. 2001) rather than ninety-eight years in the past (1901).

This background is important: it explains why RR pivots around 2000. So, RR prepends 50-99 with 19 and 00-49 with 20. Consequently RR will increasingly often default to the wrong century. It was only supposed to be a stopgap for legacy code: there is no excuse for using it in new applications.

Upvotes: 9

Simon
Simon

Reputation: 4475

To quote the Oracle documentation:

The RR datetime format element is similar to the YY datetime format element, but it provides additional flexibility for storing date values in other centuries. The RR datetime format element lets you store 20th century dates in the 21st century by specifying only the last two digits of the year.

Source: http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements004.htm#SQLRF00215

So basically it allows you to only specify 2 numbers of the year and Oracle will handle the century for you. In the documentation, you will also find the logic behind this. Another use is the use in queries:

The RR datetime format element lets you write SQL statements that will return the same values from years whose first two digits are different.

Upvotes: 5

Related Questions