Need to check if the given date falls between two date

For example:03/28/2022

And my two dates are 03/01/2022 and 03/31/2022

Need to check if 03/28/2022 falls between
03/01/2022 and 03/31/2022

Hi @sruthesanju

Try this

inputDate = DateTime.ParseExact("03/28/2022", "MM/dd/yyyy", CultureInfo.InvariantCulture)
startDate = DateTime.ParseExact("03/01/2022", "MM/dd/yyyy", CultureInfo.InvariantCulture)
endDate = DateTime.ParseExact("03/31/2022", "MM/dd/yyyy", CultureInfo.InvariantCulture)

If inputDate >= startDate AndAlso inputDate <= endDate Then
    Log Message: "03/28/2022 falls between 03/01/2022 and 03/31/2022"
Else
    Log Message: "03/28/2022 does not fall between 03/01/2022 and 03/31/2022"

image

Cheers!!

Hi @sruthesanju

Assign: startDate = DateTime.ParseExact("03/01/2022", "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture)
Assign: endDate = DateTime.ParseExact("03/31/2022", "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture)
Assign: targetDate = DateTime.ParseExact("03/28/2022", "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture)

If (DateTime.Compare(targetDate, startDate) >= 0 AndAlso DateTime.Compare(targetDate, endDate) <= 0)
  Message Box:True
Else


@sruthesanju

isDateInRange=(DateTime.ParseExact(InputDate, "MM/dd/yyyy", CultureInfo.InvariantCulture) >= DateTime.ParseExact("03/01/2022", "MM/dd/yyyy", CultureInfo.InvariantCulture) AndAlso DateTime.ParseExact(InputDate, "MM/dd/yyyy", CultureInfo.InvariantCulture) <= DateTime.ParseExact("03/31/2022", "MM/dd/yyyy", CultureInfo.InvariantCulture))

Hi @sruthesanju

  1. Use Assign Activity to Assign All Three dates in DateTime variable.

StartDate = DateTime.ParseExact("03/01/2022", "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture)


EndDate = DateTime.ParseExact("03/31/2022", "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture)


DateToCheck = DateTime.ParseExact("03/28/2022", "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture)


  1. Use IF Activity and use below expression

DateToCheck >= StartDate AndAlso DateToCheck <= EndDate

It will Return TRUE or FALSE

Hope it will helps you :slight_smile:

@sruthesanju

(DateTime.ParseExact(InputDate, "MM/dd/yyyy", CultureInfo.InvariantCulture) >= DateTime.ParseExact("03/01/2022", "MM/dd/yyyy", CultureInfo.InvariantCulture) AndAlso DateTime.ParseExact(InputDate, "MM/dd/yyyy", CultureInfo.InvariantCulture) <= DateTime.ParseExact("03/31/2022", "MM/dd/yyyy", CultureInfo.InvariantCulture))

Hi @sruthesanju

Create a Variable with Boolean datatype called Bool_Flag.

- Assign -> Bool_Flag = If(CDate("03/01/2022") < CDate("03/28/2022") AndAlso CDate("03/31/2022") > CDate("03/28/2022"),True,false)

The Bool_Flag will give the Output as True if date is in between the two dates,
Output is False if date is not in between the tow dates.

Check the below image for better understanding,

Hope it helps!!