Formatting a DATE type in an Oracle database to only accept MMDD

dateoracle

Is there a way to limit the inputs into a DATE type in an Oracle database to only accept inputs formatted with only the day and month (not including the year)?

Best Answer

No. A date in Oracle will always have a year, month, day, hour, minute, and second. You can choose to display only certain components of the date in your front end and to give a consistent default to the other components of the date. It's pretty common, for example, to let the time component of the date default to midnight. You could force the year to be some default as well that is never shown. I'm not sure, though, where that would ever be useful.

Depending on what you are actually trying to represent, you may be better off storing the data as an interval.