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.
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”))
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 @HsDev
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.
This means if it’s saturday add 2 days, else process the second if which says if it’s Sunday add 1 day, otherwise just return today (Now). Note the above is pseudocode with the intent of just showing how an if expression works.
if(condition,do if true,do if false)
What I’ve done here is…
if(condition,Do if true,another if(condition,do if true,do if false))