Skip to content
Advertisement

Oracle SQL Extract Year from VARCHAR2

Please don’t roast me for not being able to figure this out. I’m a beginner with SQL and I’ve been trying to find a solution and make it work for at least a couple hours in total. I know the date fields should be stored as dates, not varchar2, but I have no control over that.

I feel like I’m close with this, just missing some magic and hoping for an assist here.

Advertisement

Answer

'ENTDAT' is a string literal.

ENTDAT (without the quotes) could be a column name.

So if your column name is ENTDAT you probably wanted:

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