Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Replace TO_CHAR function to get current month data

NagaJun 6 2018 — edited Jun 7 2018

Hi,

I have below query to return records that are created in the current month and data is created in last 14 days ( 'mm' and 'yyyy' check is to ignore last month data if the query runs on first week or early 2nd week of the month).

Is there a way to tune below query to replace TO_CHAR function to get data for the current month with less than 14 days.

select * from Table_1

where source_col ='BIT'

and create_dts > sysdate -14

and TO_CHAR(create_dts, 'mm') = TO_CHAR(SYSDATE, 'mm')

and TO_CHAR(create_dts, 'yyyy') = TO_CHAR(SYSDATE, 'yyyy');

Thanks!

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 5 2018
Added on Jun 6 2018
12 comments
974 views