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_date ()

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

Share

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

This article mainly introduces what pit Oracle will encounter when using to_date() format date. The introduction in the article is very detailed and has certain reference value. Interested friends must read it!

To_date() formatting problem encountered when adjusting report search criteria. Details are as follows:

1. Total data 159

select * from daily_file_information;

2. Monthly data March-139 items April-16 items May-4 items

select to_char(dfi_create_time,'yyyy-mm'),count(1) from daily_file_information group by to_char(dfi_create_time,'yyyy-mm');

3. The first query method [...] between... and...】

SQL1: SQL Server 2009

select count(1) from daily_file_information where 1=1 and to_char(dfi_create_time,'yyyy-mm') between '2020-03' and '2020-05' ;

SQL2: SQL Server 2008

select count(1) from daily_file_information where 1=1 and dfi_create_time between to_date('2020-03','yyyy-mm') and to_date('2020-05','yyyy-mm') ;

4. The second query method [...] Greater than or equal to... Less than or equal to...]

SQL3: SQL Server 2008

select count(1) from daily_file_information where 1=1 and to_char(dfi_create_time,'yyyy-mm') >= '2020-03' and to_char(dfi_create_time,'yyyy-mm') = to_date('2020-03','yyyy-mm') and dfi_create_time

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