How to query for a specific day of the month in Oracle

后端 未结 3 1535
轻奢々
轻奢々 2021-01-26 19:19

Trying to automate a query that will pull data for the current month where the day of the month (in the date field) is >= the 15th. Is this possible? If so, what is the syntax t

3条回答
  •  -上瘾入骨i
    2021-01-26 19:52

    This will allow you to use any indexes you have on your date_field column:

    SELECT *
    FROM   table_name
    WHERE  date_field >= TRUNC( SYSDATE, 'MM' ) + INTERVAL '14' DAY
    AND    date_field <  ADD_MONTHS( TRUNC( SYSDATE, 'MM' ), 1 );
    

提交回复
热议问题