Invalid input syntax for type date

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hikmat
    New Member
    • Sep 2011
    • 4

    #1

    Invalid input syntax for type date

    I have written this function:


    CREATE OR REPLACE FUNCTION get_date2(idate date) RETURNS date AS $$
    DECLARE
    tmp text;

    BEGIN
    SELECT to_char(idate, 'FMDDth FMMon YYYY') into tmp;
    return tmp::date;
    END;

    $$ LANGUAGE 'plpgsql';

    But when I try to use the function I get this error:

    my_dbs=#select get_date2('01/02/1989');
    ERROR: invalid input syntax for type date: "1st Feb 1989"
    CONTEXT: PL/pgSQL function "get_date2" line 6 at RETURN

    any help will be appreciated
    Last edited by Niheel; Sep 20 '11, 03:27 PM. Reason: Moved to own question from end of old thread
Working...