Please take this survey to help us learn more about how you use third party tools. Your input is greatly appreciated!

Comparing Two Dates

Jim Knicely authored this post.

There are several cool built-in functions that you can use to compare two dates.


dbadmin=> SELECT today,
dbadmin->        yesterday,
dbadmin->        DATE_EQ(today, yesterday) AS date_equal,
dbadmin->        DATE_GE(today, yesterday) AS date_greater_than_or_equal,
dbadmin->        DATE_GT(today, yesterday) AS date_greater_than,
dbadmin->        DATE_LE(today, yesterday) AS date_less_than_or_equal,
dbadmin->        DATE_LT(today, yesterday) AS date_less_than
dbadmin->   FROM (SELECT sysdate::date AS today,
dbadmin(>                (sysdate-1)::date AS yesterday) foo;
   today    | yesterday  | date_equal | date_greater_than_or_equal | date_greater_than | date_less_than_or_equal | date_less_than
 2018-07-25 | 2018-07-24 | f          | t                          | t                 | f                       | f
(1 row)

Have fun!

Sign In or Register to comment.

Can't find what you're looking for? Search the Vertica Documentation, Knowledge Base, or Blog for more information.