简体   繁体   中英

Oracle query to extract data between 2 days for every month

How to extract data between 2 days for every month. For example, say the date range is between 2nd and 10th. Then I need to extract data for 2nd and 10th of every month from the table.

Use EXTRACT

SELECT *
FROM   table_name
WHERE  EXTRACT( DAY FROM date_column ) BETWEEN 2 AND 10;

or TO_CHAR then TO_NUMBER :

SELECT *
FROM   table_name
WHERE  TO_NUMBER( TO_CHAR( date_column, 'DD' ) ) BETWEEN 2 AND 10;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM