Skip to main content

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

  • March 1, 2017
  • 1 reply
  • 11 views

Slaagh
Forum|alt.badge.img+1
  • Participating Frequently

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()))));

1 reply

Slaagh
Forum|alt.badge.img+1
  • Author
  • Participating Frequently
  • March 1, 2017

Here is the answer...

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