Error when trying to create a function

Database

Error when trying to create a function

Hi, I am trying to create my first function in Teradata SQL Assistant using a script I found on the internet.  the purpose of the function is to convert a timestamp to a unix timestamp and is as follows;

CREATE OR REPLACE FUNCTION oracle_to_unix(in_date IN DATE) RETURN NUMBER 

IS 

BEGIN 

  RETURN (in_date -TO_DATE('19700101','yyyymmdd'))*86400 -   TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone),1,3))*3600; END;

when I try to run this sql I get the error "Data Type "in_data" does not mata Defined Data type.  

1 REPLY
Junior Contributor

Re: Error when trying to create a function

This is Oracle source code, of course it's not working as-is on Teradata.

See http://forums.teradata.com/forum/general/convert-13-digit-epoch-time-to-date#comment-148179 for an example to cast a Timestamp to epoch time.