# Check if Day is between 20th and 5th of any month

Hi There guys,

My problem is that I have to check if today’s date is between 20th and 5th of any given month - instead of using a long If statement of Today.Date.Day= 20 etc - would anyone know of a more simplified statement to determine If today’s day is between the 20th and 5th of a month?

Many Thanks!

one of many options

2 Likes

Hi @Kyleb91

You can give this in If condition to check whether todays date is between 20th and 5th of any given month.

``````strinput.Day>=20 AndAlso strinput.day<=5
``````

You can do the further process.

Regards,

1 Like

@Kyleb91
If you find solution for the query please mark it as solution to close the loop.
Happy Automation
Regards,

1 Like

Thanks very much that’s a lovely method - although would this still work between 20 and 5 of a month ie: 20th-31st, and 1st-5th - as it would just keep going up from 20 and not reach 5 again if you get me.

Thanks man - although i am trying to get 20th-31st and 1-5 so this would need to be an OR and not AndAlso

@Kyleb91

Yes you are right:
the condition is:

``````strinput.Day>=20 Or strinput.day<=5
``````

Regards,

1 Like

some doubts as it is not unclear if 20 to end month and 1 to 5 from same month or for previous / following month is meant

1 Like

Sorry, So i mean 21st -31st of any month and 1st-5th of any month

if I got it rigth:

There’s no way to tell it to circle back around to 1 from 31. So you’d need to adjust your logic.

“Is between 21-31 or is between 1-5” is the same as “is not between 6-20”

First condition: `startNum < endNum AND Enumerable.Range(startNum,endNum).Contains(checkNum)`

Second condition: `startNum > endNum AND NOT Enumerable.Range(endNum-1,startNum+1).Contains(checkNum)`

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