[CLUE-Tech] postgres function

Jason Friedman jason at powerpull.net
Sun Jun 9 07:09:57 MDT 2002


I want to write a function which accepts a timestamp and returns the 
date portion only.

I've tried:

CREATE FUNCTION extract_day(timestamp)
RETURNS date
AS 'SELECT DATE_TRUNC('day', $1);'
LANGUAGE 'sql';

but get a ERROR:  parser: parse error at or near "day"

Whereas:

select date_trunc('day',current_timestamp);
-[ RECORD 1 ]----------------------
date_trunc | 2002-06-09 00:00:00+00




More information about the clue-tech mailing list