If its Friday or Saturday, Select Monday

I’m trying to find the most efficient way to code this.

    IF Date.Now.DayOfWeek.ToString = "Friday" OR Saturday 

      Then the new date should become the Monday that follows. 

The date needs to be returned as a short date string so that it
can be entered into the date field on the application form that I’m automating.
This is what I was going to do, but I feel like maybe someone has a better way of doing this.

IF  dayofweek = friday

   Date.Add(3 days) 

ELSE IF dayofweek = saturday

   Date.Add(2 days)

Else It's not the weekend yet.
2 Likes

@Heathersmithx

The one you tried is the correct one and easiest way.

1 Like

I just wish it could be a one liner I guess. Lol.

1 Like

Hello @Heathersmithx,
You could use Switch case.

image

1 Like

Hi @Heathersmithx,

Here I have attached the sample to your situation handle by switch case.

Sample : Heathersmithx.zip (11.4 KB)

Regards
Balamurugan.S

1 Like

hmmm fine
may be like this lol
say if we have a variable of type string named in_day with value as “Friday” then
to be in a single line

If(in_day.ToString.ToUpper.Equals(“FRIDAY”),DateTime.Now.AddDays(3),If(in_day.ToString.ToUpper.Equals(“SATURDAY”),DateTime.Now.AddDays(2),“Its not a weekend”))

hope this would help you
Cheers @Heathersmithx

1 Like

may be in a assign activity with this single expression
out_date_string = If(in_day.ToString.ToUpper.Equals(“FRIDAY”),DateTime.Now.AddDays(3).DayOfWeek.ToString,If(in_day.ToString.ToUpper.Equals(“SATURDAY”),DateTime.Now.AddDays(2).DayOfWeek.ToString,“Its not a weekend”))

where this out_date_string is a string variable
cheers @Heathersmithx

1 Like

Hi I’m a little confused with Switch. I’m looking for something similar using Switch also. If Day of the week is Monday then assign Friday (previous) otherwise yesterday.