Free Trial

Alteryx Designer Desktop Discussions

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

Multiple IF AND Statement with Dates

nafarrar34
5 - Atom

Hello, I am trying to create an IF Statement to assignment Invoice Dates to a particular Payment Batch. My statement is...

 

IF [Date]>=[Current Month Start] AND DATE<= DateTimeDay(2022-08-15)
THEN "08/01/2022-08/15/2022"

ELSE IF [Date]>DateTimeDay(2022-08-15) AND DATE<=[Current Month End ]
THEN "08/16/2022-08/31/2022"
ELSE "Prior Month"
ENDIF

 

The Syntax appears correct, but I am still receiving an error. Any assistance would be greatly appreciated. Thank you

3 REPLIES 3
DataNath
17 - Castor
17 - Castor

IF [Date]>=[Current Month Start] AND DATE<= DateTimeDay(2022-08-15) <- Date here needs to be in quotes i.e. '2022-08-15'

ELSE IF [Date]>DateTimeDay(2022-08-15) AND DATE<=[Current Month End ] <- Same here. Also, 'ELSE IF' should be 'ELSEIF'.

 

A couple of points:

 

1) Whilst I think Alteryx still handles it (I've not checked personally), field names should be in square brackets and you currently have a couple of instances of DATE instead of [DATE].

2) While I'm not 100% sure what the use case of this, from the outcomes in your if statement it looks like you should just be comparing to the actual date of '2022-08-15' itself, rather than using DateTimeDay(). DateTimeDay() checks what day of the month it is and so you're trying to compare your [DATE] field to 15 in this case.

 

Perhaps the desired statement is the following?

 

IF [Date]>=[Current Month Start] AND [DATE] <= '2022-08-15'
THEN "08/01/2022-08/15/2022"
ELSEIF [Date] > '2022-08-15' AND [DATE] <= [Current Month End ]
THEN "08/16/2022-08/31/2022"
ELSE "Prior Month"
ENDIF

 

 

Let us know if you still need further help. Thanks!

MilindG
12 - Quasar

MilindG_0-1664482306564.png

Maybe add the '' in your datetimeday and see if that fixes the problem

nafarrar34
5 - Atom

Thank you both! The DateTime function was the wrong one to be using for my purpose. Appreciate your help.

Labels
Top Solution Authors