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
user
27-11-2019 14:00:32 -0500
code

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](https://community.denodo.com/docs/html/browse/7.0/vdp/vql/appendix/syntax_of_condition_functions/date_processing_functions#to-localdate) to convert it. You can read the [Teradata SQL to Denodo VQL Quick Reference](https://community.denodo.com/kb/view/document/Teradata%20SQL%20to%20Denodo%20VQL%20Quick%20Reference?category=VQL) Knowledge Base article and the [Datetime Processing Functions](https://community.denodo.com/docs/html/browse/7.0/vdp/vql/appendix/syntax_of_condition_functions/date_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
code
You must sign in to add an answer. If you do not have an account, you can register here