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

Date/Time Functions are working wrong

Vertica version 9.2 Date/Time Functions are working wrong
when we provide column_name which contains many rows with "DateTime" (Column Sample: 2019-05-11 23:45:29), the hour value in output we receive is completely wrong when compare to actual hour from actual table (column_name)
For Example: ** Column Sample: 2019-05-11 23:45:29`
--SELECT HOUR ( "column_name");--
Output: 12(Instead of 23. I got 12).
--SELECT TIMESTAMP_TRUNC("column_name",'HH'),"column_name",TRUNC("column_name") FROM Table_Name;--
-- SELECT TO_CHAR ("column_name", 'HH24:MI:SS') AS my_date FROM Table_Name; --
But Hard-code is working correctly
For Example: --SELECT HOUR (TIMESTAMP '2019-05-11 23:45:29');--
--SELECT HOUR ( '2019-05-11 23:45:29');--
I don't know y these functions are wrongly calculating. Can anyone Help to solve this issue?


  • Bryan_HBryan_H Administrator

    Instead of a column sample, could you post a test case that reproduces the issue? This simple case works for me, so how is your table and query different than the following:

    dbadmin=> CREATE TABLE testing(c1 TIMESTAMP);
    dbadmin=> INSERT INTO testing VALUES ('2019-05-11 23:45:29');
    (1 row)
    dbadmin=> SELECT HOUR(c1) from testing;
    (1 row)

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file

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