Skip to main content

ISDATE equivalent in Vertica

  • May 16, 2016
  • 1 reply
  • 10 views

eavilaj

ISDATE equivalent in Vertica

1 reply

eli_revach
Forum|alt.badge.img+2
  • Participating Frequently
  • May 16, 2016

 

Hi 


Below is an example for  the new casting capability vertica has 
SELECT a::!int FROM mytable;


The above casting simulte is_numeric()  function and return null if the value is not numeric , you can do the same test with date or timestamp 

 

In the below example you can see that when the value is not a  date  , the return value is null  :

 

dbadmin=> create table t3 (s varchar(20));

CREATE TABLE

dbadmin=> insert into t3 values('2012-10-10');

 OUTPUT

--------

      1

(1 row)

 

dbadmin=> insert into t3 values('abc');

 OUTPUT

--------

      1

(1 row)

 

dbadmin=> SELECT s::!timestamp from t3;

          s

---------------------

 

 2012-10-10 00:00:00

(2 rows)

 

Thanks