0

I have some dates like 20190101 (YYYYMMDD) and 201901 (YYYYMM) in a column called process_date and I need two columns, a column called process_year with the year (YYYY) and process_month with the month (MM), when I use

date_part('year',process_date::numeric(8,0)) as process_year

the dates in format 201901 (YYYYMM) take the value '20' and same with

date_part('month',process_date::numeric(8,0)) as process_month

take the value '19' to the same format 201901 (YYYYMM)

mufazmi
  • 1,103
  • 4
  • 18
  • 37

1 Answers1

0

I found one method:

substr(process_date,1,4) as process_year

and

substr(process_date,5,2) as process_month

Thanks for your help.