We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Create a date condition and count days in date period

MonaAlmutairi
8 - Asteroid

Hey everyone,

 

I'm seeking your support in creating a condition to include specific records in a table and then count the days in the period depening on a condition.

 

My condition is: I want the records that include days in "2023"

 

For example:

 

Employee Start DateEnd Date
101/15/202301/17/2023
212/28/202201/04/2023

 

 

I should give the rows #1 and #2 to be included. Then, I need to count only the days in "2023". See below:

 

Employee Start DateEnd DateDays
101/15/202301/17/20233
212/28/202201/04/20234

 

 

 

Thank you :) 

2 REPLIES 2
ShankerV
17 - Castor

Hi @MonaAlmutairi 

 

Please use the below formula to achieve your result in the Formula tool.

 

IF DateTimeParse([Start Date],"%m/%d/%y")>="2023-01-01"
THEN
DateTimeDiff(DateTimeParse([End Date],"%m/%d/%y"), DateTimeParse([Start Date],"%m/%d/%y"),"days")+1
ELSE
DateTimeDiff(DateTimeParse([End Date],"%m/%d/%y"), "2023-01-01","days")+1
ENDIF

 

Many thanks

Shanker V

MonaAlmutairi
8 - Asteroid

@ShankerV  You are a live saver!! Thank you!

Labels
Top Solution Authors