Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What kind of pit will Oracle encounter when formatting a date with to_char ()

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you the "Oracle using to_char () formatting date will encounter what pit", the content is easy to understand, clear, hope to help you solve the doubt, the following let the editor lead you to study and learn "Oracle use to_char () formatting date will encounter what pit" this article.

1. View the current system time

The current time is 11:18:51 on May 14, 2020.

SQL: select sysdate from daul

2. Yyyy-mm-dd format

Commonly used formatting

SQL: select to_char (sysdate,'yyyy-mm-dd') from daul

3. Yyyy-mm-dd hh34:mm:ss format

Select to_char (sysdate,'yyyy-mm-dd hh34:mm:ss') from daul

4. Yyyy-mm-dd hh34:mi:ss format

SQL: select to_char (sysdate,'yyyy-mm-dd hh34:mi:ss') from daul

5. Compare the results and view the problems

Question:

It is currently 11:20, while the third step formatting results in 11:05

Reason:

SQL is not case-sensitive, and Oracle treats "mm/MM" as a month when formatting.

Oracle's SQL uses mi instead of minutes, which is usually written as "yyyy-mm-dd hh34:mm:ss" in the development process.

The correct format is: "yyyy-mm-dd hh34:mi:ss", remember!

The following figure refers to the comparison result: it is obvious that the first row of data mm is the current month

The above is all the contents of the article "what will happen if Oracle uses to_char () to format the date?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report