how to get varchar date format into date

Hi Experts,

I have source table with column persistent_date and data was like this

persistent_date

January 2025
February 2025


December 2025

But I want output like below

persistent_date

01- 2025
02- 2025


12-2025

Thanks,
Venki


ursfriend77 (BOB member since 2011-03-02)

Lots of different ways to solve that. Here is one:

print('January 2025');

print(to_char(to_date(word_ext('January 2025', 1, ' ') || ' 01 ' || word_ext('January 2025', 2, ' '), 'MONTH DD YYYY'), 'MM-YYYY'));

Output:

10852	9332	PRINTFN	3/27/2017 2:55:58 PM	January 2025
10852	9332	PRINTFN	3/27/2017 2:55:58 PM	01-2025

eepjr24 :us: (BOB member since 2005-09-16)

Hi,

You can also use the following:

to_char( to_date(persistent_date,‘Month YYYY’),‘MM-YYYY’)

Regards,
Jayant


Jay_mKumar :india: (BOB member since 2016-03-24)