Convert function (need help. posted this a long time ago. Is this site active?)

edited March 2017 in General Discussion

Hello,
I have the following WHERE clause in a SQL script that I am trying to turn into a Vertica view. It is my understanding that CONVERT does not exists in Vertica. Does anyone know how to do this in Vertica? I am basically looking for the first of January, 3 years ago.

WHERE DATETIMESTAMP >= CONVERT(DATETIME,'01-01-'+CONVERT(VARCHAR(5),YEAR(DATEADD(YYYY,-3,GETDATE()))));

Comments

  • Here is the answer...

    WHERE TO_CHAR(DATETIMESTAMP) >= '01-01-'||TO_CHAR(YEAR(GETDATE())) - 3;

Leave a Comment

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