Reputation: 273
I want to write a query which returns the month only in 3 characters but the first character should be Capital and the rest non-capital. For example DEC should be (Dec) or JAN (Jan).
select substr(sysdate,4,3) from dual;
SQL code above returns the month but in capital "DEC", so I want the output as "Dec".
Does anyone know how to achieve it?
Thanks
Upvotes: 2
Views: 188
Reputation: 3950
this will work indeed jus to use an extra function that is initials with caps on :
select initcap(substr(sysdate,4,3)) from dual;
Upvotes: 0
Reputation: 2024
There is no need for manipulation, as stated in previous answers.
You can simply write this:
SELECT TO_CHAR (SYSDATE, 'Mon', 'nls_date_language=American') FROM DUAL;
If you'd pass 'Month' as the second parameter you'd get 'December', if you'd pass 'month' you'd get 'december' and if you pass 'Mon' you will get 'Dec', as you have asked.
I hope I helped!
Upvotes: 3