I needed function to check if a string was a valid date and noticed that there weren't any posts after searching a bit. Here is a quick and dirty function to check for this....
CREATE OR REPLACE FUNCTION isdate(mydate text) RETURNS boolean AS
$$
DECLARE
a date;
BEGIN
if mydate is NULL then
RETURN 'f';
end if;
a := mydate::timestamp;
RETURN 't';
EXCEPTION
WHEN others THEN RETURN 'f';
END;
$$ LANGUAGE 'plpgsql';
If you have a better method, please post.
Gary
gwinn7
CREATE OR REPLACE FUNCTION isdate(mydate text) RETURNS boolean AS
$$
DECLARE
a date;
BEGIN
if mydate is NULL then
RETURN 'f';
end if;
a := mydate::timestamp;
RETURN 't';
EXCEPTION
WHEN others THEN RETURN 'f';
END;
$$ LANGUAGE 'plpgsql';
If you have a better method, please post.
Gary
gwinn7