Multiple IF AND Statement with Dates
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
Solved! Go to Solution.
- Labels:
- Date Time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Maybe add the '' in your datetimeday and see if that fixes the problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thank you both! The DateTime function was the wrong one to be using for my purpose. Appreciate your help.
