sql - Check whether string is a date Postgresql -


is there function in postgresql returns boolean whether given string date or not mssql's

isdate("january 1, 2014")

thanks!

you can create function:

create or replace function is_date(s varchar) returns boolean $$ begin   perform s::date;   return true; exception when others   return false; end; $$ language plpgsql; 

then, can use this:

postgres=# select is_date('january 1, 2014');  is_date ---------  t (1 row)  postgres=# select is_date('20140101');  is_date ---------  t (1 row)  postgres=# select is_date('20140199');  is_date ---------  f (1 row) 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -