Within a plpgsql-function I have a simple insert statememt:
insert into table_Y (column1 ,
column2 ,
//more columns
int_date , -- example: '20190714'
//more columns
)
select value1 ,
value2 ,
//more values
date_value::integer ,
//more values
from table_X
Column "date_value" in table table_X is of type date. Column int_date in table table_Y is of type integer ... so with the following expression:
date_value::integer
... I want to convert the value from column "date_value" to an integer (e.g. from 14. July 2019 to '20190714').
However, I'm getting the following error message:
ERROR: cannot cast type date to integer
How can I convert the date to an integer instead?
P.S.: the solution to this question: convert date to integer in postgresql does not help in my case becasue I don't want the number of days.