Insert dates before 1950 in Oracle

I have a problem with the correct date. When I copy dates from one table to another

insert into table1 select some_date from some_table 

he inserts an invalid date. The problem only occurs for dates from the year before 1950. In table 1, I have the date 1.1.1949, and when I copy it to some_table, I get the date 2049-1-1

How do I get the correct date ... 1949-1-1?

+4
source share
1 answer

You should use:

 to_char(some_date,'YYYY-MM-DD') 

RRRR are two-digit years, assuming the same century. Read here: What is the difference between "YYYY" and "RRRR" in Oracle SQL .

+6
source

Source: https://habr.com/ru/post/1436412/


All Articles