Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Query data between two dynamic date ranges.

Tybo
7 - Meteor

I have searched for hours and could not find an answer that works.

 

Here is my query with specific table names and irrelevant data starred out. 

 

---------------------------------------------------------------------------------------

Select ******, ******, ******, ...suggested_Due_Date

From *********Table Name

Where *****=*****

and ....suggested_Due_Date >= today-7 days and <= today+83 days

------------------------------------------------------------------------------------------

I've tried several combinations after much searching with only errors coming from an issue with the code for the date range. 

4 REPLIES 4
apathetichell
18 - Pollux

is your [Due-Date] a date field in Alteryx? if so - use a customer filter with [suggested_Due_Date]>=datetimeadd(datetimenow(),-7,"days") and [suggested_Due_Date]<=datetimeadd(datetimenow(),83,"days")

 

Tybo
7 - Meteor

This did not fix my error. "Error is Analysis Exception: default.datetimenow() unknown."

my data source is datetime

Tybo
7 - Meteor

I wanted to also specify I am doing this in the SQL editor and not using the filter tool on the canvas.

apathetichell
18 - Pollux

What type of SQL are you using. This is really a SQL query question and has 0% connection to Alteryx - other than that you are using Alteryx to execute the query.

 

Something like CAST( GETDATE() AS Date ) will get you today's date and something like DATEADD(day, -7, AST( GETDATE() AS Date ) ) might get you one of your values. You'll need two clauses in your Where statement - and an AND to join them. You are not looking for value > and < you are looking for value > and value <.

 

 

Labels