How to check if current day of week is between monday to thursday

I was trying to check a condition where current day of week is between Monday and Thursday

for e.g. if current day is Tuesday than the condition is true

i tried this expression

var CurrentDate = DateTime.Now

If( (CurrentDate.DayOfWeek > CurrentDate.DayOfWeek.Equals("Monday")) and (CurrentDate.DayOfWeek < CurrentDate.DayOfWeek.Equals("Thursday")))

but im getting this error

Option Strict On disallows implicit conversion from 'Boolean' to 'String'

Hi @indiedev91

You’re encountering an error in comparing the DayOfWeek enumeration with a string value. To check if the current day of the week is between Monday and Thursday, you should compare it with the corresponding DayOfWeek enumeration values, which are integers.

Could you please use the following expression once?

var CurrentDate = DateTime.Now

If (CurrentDate.DayOfWeek >= DayOfWeek.Monday AndAlso CurrentDate.DayOfWeek <= DayOfWeek.Thursday)

Hope this helps,
Best Regards.

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