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

How to realize the sql condition of querying today's data by oracle

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces oracle how to achieve the sql conditions for querying the same day's data, which has a certain reference value, and interested friends can refer to it. I hope you will gain a lot after reading this article.

Daily data statistics will use the query of the current day's data, the following are the conditions for the date to be corresponding:

Between

To_date (to_char (sysdate,'yyyy-mm-dd') | |'00 and 0015 01mm hh34:mi:ss') and

To_date (to_char (sysdate,'yyyy-mm-dd') | |'23 sysdate,'yyyy-mm-dd' 59 hh34:mi:ss')

Oracle

The field type is varchar2, and the format should match the formatted style

Current day select * from table name where to_char (to_date (field name, 'yyyy-mm-dd hh34:mi:ss'),' dd') = to_char (sysdate,'dd') current week select * from table name where to_char (to_date (field name, 'yyyy-mm-dd hh34:mi:ss'),' iw') = to_char (sysdate,'iw') current month select * from table name where to_char (to_date (field name, 'yyyy-mm-dd hh34:mi:ss')) 'mm') = to_char (sysdate,'mm') current quarter select * from table name where to_char (to_date (field name,' yyyy-mm-dd hh34:mi:ss'),'Q') = to_char (sysdate,'q')

Field type is date

Current day select * from table name where to_char (field name, 'dd') = to_char (sysdate,'dd') current week select * from table name where to_char (field name,' iw') = to_char (sysdate,'iw') month select * from table name where to_char (field name, 'mm') = to_char (sysdate,'mm') current quarter select * from table name where to_char (field name,' q') = to_char (sysdate,'q')

SQL

Select * from table name where DATEPART (dd, field name) = DATEPART (dd, GETDATE ()) and DATEPART (mm, field name) = DATEPART (mm, GETDATE ()) and DATEPART (yy, field name) = DATEPART (yy, GETDATE ()) that week select * from table name where DATEPART (wk, field name) = DATEPART (wk, GETDATE ()) and DATEPART (yy, field name) = DATEPART (yy, GETDATE ()) month select * from table name where DATEPART (mm, field name) = DATEPART (mm GETDATE () and DATEPART (yy, field name) = DATEPART (yy, GETDATE ()) current quarter select * from table name where DATEPART (qq, field name) = DATEPART (qq, GETDATE ()) and DATEPART (yy, field name) = DATEPART (yy, GETDATE ()) Thank you for reading this article carefully I hope the article "oracle how to realize the sql conditions for querying the same day's data" shared by the editor will be helpful to you. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

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

Database

Wechat

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

12
Report