当前位置:网站首页>Solve the problem that the time format of manually querying Oracle database is incorrect (date type)

Solve the problem that the time format of manually querying Oracle database is incorrect (date type)

2022-07-23 11:24:00 Sun Junchen

When writing code , It is often first to use visual tools to query the database for testing , Then write code according to the query statement

When the database is used Oracle And there are DATE Type , Will use string conversion DATE Function of TO_DATE(ch, fmt)

If fmt( The format of the date ) Use yyyy-MM-dd HH:mm:ss

for example :TO_DATE('2020-05-20 13:14:20' , 'yyyy-MM-dd HH:mm:ss') 

In this way, mistakes will occur : ORA-01810: The format code appears twice

resolvent :

        take mm Change it to mi, The detailed method is as follows

Using functions TO_DATE(ch, fmt)

ch: Input time ( character string )

fmt: The format of the date

        12 hourly :yyyy-MM-dd HH:mi:ss

        24 hourly :yyyy-MM-dd HH24:mi:ss

for example :TO_DATE('2020-05-20 13:14:20' , 'yyyy-MM-dd HH24:mi:ss') 

原网站

版权声明
本文为[Sun Junchen]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/204/202207230537525725.html