How to set if / then statement base on week of the date?

I am trying to use if / then activity based on the date of the week. If it’s Monday the date will be entered should be last Friday " " +Datetime.Today.AddDays(-3).ToShortDateString and other then that it would be the previous date " " +Datetime.Today.AddDays(-1).ToShortDateString. Any pointer on what should I enter in the IF statement?

Thanks

@ruei

To check whether the current day is Monday use the below expression in IF condition.

datetime.Now.DayOfWeek.ToString.Equals("Monday")

Regards,
Ranjith

thanks @ranjith what about entering two dates in type into? Such as 9/21/2018 9/22/2018 without any comma?

@ruei

In type into just concatenate the two strings using + operator dateone.tostring+datetwo.tostring

Eg :

β€œ9/21/2018”+β€œ9/22/2018” Try this one to enter 9/21/20189/22/2018 (without spaces)

or
β€œ9/21/2018”+" "+β€œ9/22/2018” With space inbetween 9/21/2018 9/22/2018

Regards,
Ranjith.

thanks again @ranjith is it possible to make the date dynamic?
This is what I am using.
β€œβ€+Datetime.Today.AddDays(-3).ToString+Datetime.Today.AddDays(-1).ToString

Any thoughts on this?

1 Like

@ruei yes you can use the above expression. Additionally you can also determine the format of the Date while converting to string.
Datetime.Today.AddDays(-3).ToString("dd/MM/yyyy")+Datetime.Today.AddDays(-1).ToString("dd/MM/yyyy")

Regards,
Ranjith