Skip to content
Advertisement

Oracle SQL – Define the year element of a date dependent on the current month

I am trying to create a view in SQL Developer based on this statement:

SELECT * FROM ORDERS WHERE START_DATE > '01-JUL-2020'

The year element of the date needs to set to the year of the current date if the current month is between July and December otherwise it needs to be the previous year.

The statement below returns the required year but I don’t know how to incorporate it (or a better alternative) into the statement above:

Thanks

Advertisement

Answer

Oracle doesn’t have a built-in month function so I’m assuming that is a user-defined function that you’ve created. Assuming that’s the case, it sounds like you want

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement