You can translate the question and the replies:

How to use dynamic dates in where clause

I am creating a view out of a Teradata database that has the date columns formated as YYYYMM and YYYY-MM-DD. Rather than a date WHERE condition based off of a static date such as '2019-10-31', I want a range based of a dynamics dates such as "ADD_MONTHS(CURRENT_DATE - EXTRACT(DAY FROM CURRENTDATE), 0)" assuming today is 11/27/19. PS - I am a very new user to Denodo
27-11-2019 14:00:32 -0500

1 Answer

Hi, If you would like to use a WHERE condition with a dynamic rather than static date value, you can specify a combination of functions in the WHERE clause expression. Upon reading your question, I noticed that you are using Teradata functions. To implement your scenario in Virtual DataPort, you will need to find the Denodo equivalents of those functions. For example, the WHERE condition equivalent of what you have listed would be: `WHERE <column_name> = ADDMONTH(ADDDAY(CURRENT_DATE, (EXTRACT(DAY FROM CURRENT_DATE) * -1)), 0)` Note: The column in your WHERE clause must be of "date" data type. If it is in text format, you can use [TO_LOCALDATE]( to convert it. You can read the [Teradata SQL to Denodo VQL Quick Reference]( Knowledge Base article and the [Datetime Processing Functions]( section of the Virtual DataPort VQL Guide to find all of the Denodo equivalents of Teradata functions and additional information on this topic. Hope this helps!
Denodo Team
27-11-2019 20:11:56 -0500
You must sign in to add an answer. If you do not have an account, you can register here