Need Logic in switch case

Need logic either switch case or if conditions
Switch case is better

Please find attachment for more details

Please give me conditions,
I received process date in string format
MM/DD/yyyy

Thanks and regards,
Vicky

1 Like

Hi @Vicky_K

You can use a FlowChart to achieve the same.

DateTime.Now.AddDays(10).ToString("MM/dd/yyyy") = Now.ToString("MM/dd/yyyy")

Use the above expression to formulate the specific conditions and design the flow.

Hope this helps,
Best Regards.

Hi

I think IF condition in sequence is much easier with this or go for a FLOW DECISION in a flowchart

Let’s take IF condition like this

Datetime.ParseExact(yourdatestring.ToString.Substring(0,10), “MM/dd/yyyy”, System.Globalization.CultureInfo.InvariantCulture).AddDays(10).ToString(“dd/MM/yyyy”).Equals(Datetime.Now.ToString)

If true it goes to then block where u can send the mail or goes to else block where use another IF condition like this

Datetime.ParseExact(yourdatestring.ToString.Substring(0,10), “MM/dd/yyyy”, System.Globalization.CultureInfo.InvariantCulture).AddDays(20) >= (Datetime.Now)
AND
Datetime.ParseExact(yourdatestring.ToString.Substring(0,10), “MM/dd/yyyy”, System.Globalization.CultureInfo.InvariantCulture).AddDays(30) <= (Datetime.Now)

If true it goes to then block where send mail or goes to else block where use another IF condition like this

Datetime.ParseExact(yourdatestring.ToString.Substring(0,10), “MM/dd/yyyy”, System.Globalization.CultureInfo.InvariantCulture).AddDays(30) > (Datetime.Now)

If true it goes to then block where send the mail or goes to else block where keep it empty to ignore it

Cheers @Vicky_K

1 Like

@Vicky_K
In addition to some inputs from above we would recommend:

  • do any date compares on DateTime Datatype base
  • try to parse the check date into a variable before the checks, so you can avoid multiple same value parsings: myCheckDate = DateTime.ParseExact(…)
  • use also the Date Property for not get confused on the time part like: mxCheckDate.AddDays(20).Date >= Now.Date

Instead of falling down to nested if/else parts or others we can also use the following technique:

  • map the Compare result to a category marker
  • use the category marker within a switch activity

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