Brandon
Brandon

Reputation: 97

Converting REGEXP_REPLACE substitution to a date

I'm sure this has been answered before, but after some searching I couldn't find anything that I really understood and I know very little about SQL. I am trying to convert the returned substitution of REGEXP_REPLACE into a date.

SELECT ..., REGEXP_REPLACE("References",'.*::(.*)','\1') AS "Pay Date", ...

The returned format of the substitution \1 is MM/D(D)/YYYY e.g. 12/3/2020 or 12/13/2020.

My understanding is that you can call functions from within another function like most spreadsheet programs. e.g. REXEXP_REPLACE(TO_DATE(...,...),...) but was unable to cobble anything together that would work. I was kind of surprised I couldn't find a lot of examples of this. Any help would be appreciated.

Upvotes: 0

Views: 401

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1270663

You would use to_date() as:

SELECT TO_DATE(REGEXP_REPLACE("References",'.*::(.*)', '\1'), 'MM/DD/YYYY')

Upvotes: 2

Related Questions