Oracle code example

      century = (century byte -100) * 100  

      year = year byte - 100

    ts01>select
      2          -- extract the century and year information from the
      3          -- internal date format
      4          -- century = (century byte -100) * 100
      5          (
      6                  to_number(
      7                          -- parse out integer appearing before first comma
      8                          substr( today_dump, 1, instr(today_dump,',')-1) - 100
      9                  ) * 100
    10          )
    11          +
    12          -- year = year byte - 100
    13          (
    14                  to_number(
    15                          substr(
    16                                  today_dump,
    17                                  -- get position of 2nd comma
    18                                  instr(today_dump,',',2)+1,
    19                                  -- get position of 2nd comma - position of 1st comma
    20                                  instr(today_dump,',',1,2) - instr(today_dump,',',1,1) -1
    21                          )
    22                  )
    23                  - 100
    24          ) current_year
    25  from (
    26          -- return just the date bytes from the dump()
    27          select substr(dump(today),15) today_dump from t1
    28  ) a
    29  /

    CURRENT_YEAR
    ------------
            2004

    1 row selected.


    Example 2: Determining the century and year from the internal date format.