beckham
beckham

Reputation: 125

Oracle - Oracle function to get before and after a character

I am having a values in a column like below

"2016/01"
"2016 / 02"
"2016 /03"
"2016/ 04"

I would basically need to write a oracle query to standardize it to yyyy / mm format.

I am using the below code but its not working

ltrim(rtrim(NVL(SUBSTR(month, 0, INSTR(month, '/')-1), month))) ||' / '|| ltrim(rtrim(NVL(SUBSTR(month, 0, INSTR(month, '/')+1), month))) AS month1

Upvotes: 0

Views: 103

Answers (1)

Spock
Spock

Reputation: 327

You can try this:

CONCAT(CONCAT(SUBSTR(month,1,4),'/'),SUBSTR(month,(LENGTH(month)-1),2))

Upvotes: 1

Related Questions