'postgresql invalid input syntax for type double precision

I have a table with the birth and death of several europe monarchs, the table doesn't have have an age column and i have to add it. There are also several null and 'None' values, in that case the age column should display unknow.

the following code gives me a invalid input syntax for type double precision error.

    SELECT CASE
WHEN date_part('year', age(TO_TIMESTAMP(death, 'YYYY-MM-DD'), TO_TIMESTAMP(birth, 'YYYY-MM-DD'))) = 'None' OR death ISNULL
    THEN 'Unknown'
ELSE
    date_part('year', age(TO_TIMESTAMP(death, 'YYYY-MM-DD'), TO_TIMESTAMP(birth, 'YYYY-MM-DD')))
END

AS age FROM monarchs

postgresql doesn't have a datediff function. Many thanks.

EDIT

The birth and death columns are varchars and have this format 0208-10-01T00:53:28+00:53



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source