Date cal

Input is the data it will be like
3/13/2019

And I need to find which quarter it comes

Here is the quarter table

Quarter Startdate Enddate
1 1/1/2019 3/31/2019
2 4-1-2019 5-28-2019
3 5-29-2019 8-1-2019
4 8/2/2019 10/1/2019

The separation between the month, date and year may be “/” or “-”

For this input I will be getting the quarter as
2

you can use IF with condition like:

DateTime.ParseExact(“3/13/2019”, “d”, CultureInfo.InvariantCulture) >= QuarterBegin And <= QuarterEnd

But if separation can be either char then you need to Replace to make sure will always be the slash…

1 Like

Hello @Sweety_Girl
below post might be able to help you out…

2 Likes

Hi
Use a ASSIGN activity and mention the input date to it named str_input
Now use a FOR EACH ROW loop and mention the quarter datatable as input
And inside the loop use expression and be like this in Assign activity
str_output = IF(Datetime.ParseExact(str_input.Tostring.replace(“/“,””).Replace(“-“,””),”ddMMyyyy”, System.Globalization.CultureInfo.InvariantCulture)>DateTime.ParseExact(“row(“StartDate”).ToString.replace(“/“,””).Replace(“-“,””),”ddMMyyyy”, System.Globalization.CultureInfo.InvariantCulture) AND Datetime.ParseExact(str_input.Tostring.replace(“/“,””).Replace(“-“,””),”ddMMyyyy”, System.Globalization.CultureInfo.InvariantCulture)<DateTime.ParseExact(“row(“EndDate”).ToString.replace(“/“,””).Replace(“-“,””),”ddMMyyyy”, System.Globalization.CultureInfo.InvariantCulture), row(0).ToString,Str_output)

Where str_output is a string variable with default value as string.empty defined in the variable panel

Cheers @Sweety_Girl

1 Like

No it won’t as we have explicitly mentioned what output we need inside this IF expression
Cheers @Sweety_Girl

1 Like

Can you please attach the xml

1 Like

Were we facing any issue with that @Sweety_Girl

1 Like

image

Hello @Sweety_Girl
you can use a simple for each row or linq here btw the quarter for this input 3/13/2019 should be one right as it comes in between 1 1/1/2019 3/31/2019 this date ?

check the below workflow to understand it

Datetable.xaml (9.4 KB)

1 Like

CDate converts in this format (“dd-MM-yyyy”)

Hello @Sweety_Girl
No It converts it to this format MM-dd-yyyy but you can later convert in dd-MM-yyyy

1 Like

The expression be like this
str_output = IF(Datetime.ParseExact(str_input.Tostring.replace(“/“,””).Replace(“-“,””),”ddMMyyyy”, System.Globalization.CultureInfo.InvariantCulture)>DateTime.ParseExact(“row(“StartDate”).ToString.replace(“/“,””).Replace(“-“,””),”ddMMyyyy”, System.Globalization.CultureInfo.InvariantCulture)
AND
Datetime.ParseExact(str_input.Tostring.replace(“/“,””).Replace(“-“,””),”ddMMyyyy”, System.Globalization.CultureInfo.InvariantCulture)<DateTime.ParseExact(“row(“EndDate”).ToString.replace(“/“,””).Replace(“-“,””),”ddMMyyyy”, System.Globalization.CultureInfo.InvariantCulture),
row(0).ToString, Str_output)

Cheers @Sweety_Girl

1 Like

Kindly let know for any queries or clarification
Cheers @Sweety_Girl

1 Like

In this case 09/01/2019 if we give as 9/1/2019 its not working… It throws format issues

Hello @Sweety_Girl
I tested this date and its working fine make sure there is no invalid characters or spaces in your string use .trim method before processing it

1 Like

Worked… Thank you

Does “-”(hyphen) and “/”(slash) comes under this invalid character

no @Sweety_Girl it would’nt be considered as invalid character…
I tried with these three inputs and they worked without any errors !!

imgg

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.