This is my first 'real' script, one that verifies proper format for a user-entered date string. Once that is done I want the script to return the UNIX time. I plan on invoking this script on a psql connection (via .psqlrc), so that I can call it from the command line. Here's what I have at the end of my script, ************************************ -- ========================================== good_date := to_date(year||'-'||month||'-'||day , 'YYYY-MM-DD') ; RAISE NOTICE 'good_date = %',good_date ; Usecs := EXTRACT(EPOCH FROM TIMESTAMP good_date) ; END ; Here's what I get when I ********************* psql -U username dbname -f myfile.sql CREATE FUNCTION psql:myfile.sql:119: ERROR: syntax error at or near "$1" LINE 1: SELECT EXTRACT(EPOCH FROM TIMESTAMP $1 ) ^ QUERY: SELECT EXTRACT(EPOCH FROM TIMESTAMP $1 ) CONTEXT: SQL statement in PL/PgSQL function "usecs_from_date" near line 92 Is this not a programmable extraction??? I'm missing something here. Thanks! Ralph |