Divyanxi Mistry
Divyanxi Mistry

Reputation: 1

Can I use TRIM and TRUNC function in oracle?

using trunc function I am getting below o/p Output :01-APR-2017

I want only APR and remove rest part Can I use trim or sub-string in my query?

NOTE:- I want value in DATE format not in character format .

Upvotes: 0

Views: 3215

Answers (2)

user9037864
user9037864

Reputation: 1

If you want only month use extract function select extract(month from to_date('01-APR-2017','dd-mon-yyyy')) from dual, this will return month as 4 not APR

Upvotes: 0

ewramner
ewramner

Reputation: 6233

Your question is not very clear. To truncate a date to month:

select trunc(sysdate, 'MM') from dual;

To get only the month (as a string, a date always includes year and day):

select to_char(trunc(sysdate, 'MM'), 'MON') from dual;

If your goal is to work with date columns and compare them perhaps this will help? If not please be more explicit about what you are trying to do.

Upvotes: 1

Related Questions