Date Range Condition

Hi All,

How can I put a condition to check whether the particular date falls between 1st to 5th day of the month or it falls between 6th day of month to last date of month .

for example if the current Month is August , I need to check if the date range falls between 1st August to 5th August or the particular date falls between 6th August to 31st August.

Thanks in Advance

@marina.dutta

Assign currentDate = DateTime.Now
Assign dayOfMonth = currentDate.Day

Assign isFirstRange = dayOfMonth >= 1 AndAlso dayOfMonth <= 5
Assign isSecondRange = dayOfMonth >= 6

If isFirstRange Then
Log Message: “Date falls between 1st to 5th day of the month.”
ElseIf isSecondRange Then
Log Message: “Date falls from 6th day to the end of the month.”
Else
Log Message: “Date does not fall within the specified ranges.”
End If

Hi @marina.dutta

Assign:
   currentDate = Now                         (DataType: System.DateTime)
   dayOfMonth = currentDate.Day    (DataType: System.Int32)

If:
   Condition: dayOfMonth >= 1 AndAlso dayOfMonth <= 5
   Then:
       Log Message: "Date falls between 1st and 5th day of the month."
   Else If:
       Condition: dayOfMonth >= 6 AndAlso dayOfMonth <= DateTime.DaysInMonth(currentDate.Year, currentDate.Month)
       Then:
           Log Message: "Date falls between 6th day and last day of the month."
       Else:
           Log Message: "Date does not fall within the specified ranges."

Refer the xaml file for better understanding.
Sequence30.xaml (9.9 KB)

Hope it helps!!

Hi @marina.dutta

Assign:
currentDate = DateTime.Now

Assign:
day = currentDate.Day
month = currentDate.Month

If:
Condition: day >= 1 And day <= 5
Then:
Log Message: “Date falls between 1st and 5th”
Else:
Condition: day >= 6 And day <= DateTime.DaysInMonth(currentDate.Year, month)
Then:
Log Message: “Date falls between 6th and last day”

O/P:

I hope you understand!!

Hi @marina.dutta

=> Assign -> currentDate (System.DateTime datatype) = Now
=> Assign -> day (int datatype) = currentDate.Day
=> If (day >= 1 AND day <= 5)
        In then block give the log message "Date is in between 1st to 5th day range"
        
    Else If (day >= 6 AND day <= DateTime.DaysInMonth(currentDate.Year, currentDate.Month)):
        In else block give the log message "Date is after 6th to end day of the month"

Check the below image for workflow

Hope it helps!!

Hey @marina.dutta ,

You can use this expression in the If Activity

DateTime.Now>DateTime.Parse(“08/06/23”) AndAlso DateTime.Now<DateTime.Parse(“08/31/23”)

The above expression is for 6th August to 31st August
image

Hey @marina.dutta , any updates?

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