postgresql 判断日期是否合法

近期使用了一个非法的日期,导致存储过程ERROR,两个小时的工作白等了。

--20160430
_dateid integer; 
_tmpdate integer;

select to_char(to_timestamp(_dateid::text,'yyyyMMdd'),'yyyyMMdd')::integer into _tmpdate ;
if ( _tmpdate != _dateid ) then
  --raise notice 'dateid is invalid';
   return false;
end if;

 

posted @ 2016-06-08 14:31  haitlee  阅读(2176)  评论(0编辑  收藏  举报