How to verify if a date falls in a specified range?

Hi Community,

How to verify if a particular date falls between start date and end date.
Ex. Verify 7/26/2024 is between 07/30/2023 and 07/27/2024

I have tried using if condition as shown below:
Convert.ToDateTime(ExpectedBookDate) > Convert.ToDateTime(Startdate.ToString).ToString(“MM/dd/yyyy”) AND Convert.ToDateTime(ExpectedBookDate) < Convert.ToDateTime(Enddate.ToString).ToString(“MM/dd/yyyy”)

It’s throwing error whether ExpectedBookDate is of type String or DateTime

BC30512: Option Strict On disallows implicit conversions from ‘String’ to ‘Date’. The selected value is incompatible with the property type.

Please help me with the logic. I’m using 2023 version

Hi @Vaishnav_Tej

Check below post for your reference

Hope this may help you


Hi @Vaishnav_Tej

Please try this

DateTime.ParseExact(ExpectedBookDate, "MM/dd/yyyy", CultureInfo.InvariantCulture) >= Startdate AndAlso DateTime.ParseExact(ExpectedBookDate, "MM/dd/yyyy", CultureInfo.InvariantCulture) <= Enddate

Hope this helps!!

Hi @Vaishnav_Tej

ExpectedBookDate = "7/26/2024"
StartDate = "07/30/2023"
EndDate = "07/27/2024"

expectedDate = DateTime.ParseExact(ExpectedBookDate, "M/d/yyyy", System.Globalization.CultureInfo.InvariantCulture)
startDateObj = DateTime.ParseExact(StartDate, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture)
endDateObj = DateTime.ParseExact(EndDate, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture)

If expectedDate >= startDateObj AndAlso expectedDate <= endDateObj Then
    ' The ExpectedBookDate falls between StartDate and EndDate
    ' Do something here
    ' The ExpectedBookDate does not fall between StartDate and EndDate
    ' Do something else here
End If

Note: ExpectedBookDate, StartDate, EndDate are of DataType System.String. expectedDate, startDateObj, endDateObj is of DataType System.DateTime.

Hope it helps!!


I’m getting this error :
BC30451: ‘CultureInfo’ is not declared. It may be inaccessible due to its protection level. Variable ‘CultureInfo’ is missing. Please use Data Manager to recreate it.


In that case try this


use this




I’m getting this error :



Try this syntax:

expectedDate= DateTime.ParseExact(ExpectedBookDate, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture)

Still same error. do I need to download any package?


If(CDate(ExpectedBookDate)>CDate(startdate) And CDate(ExpectedBookDate)<CDate(Enddate),“T”,“F”)

Hi What should be the variables data type?


expectedDate is an DateTime variable. Make sure you have given the datatype System.DateTime.


Yes I have given as you mentioned

I’m getting this error

If: Conversion from string “” to type ‘Date’ is not valid.

I have given this condition in the IF Activity

CDate(ExpectedBookDate)>CDate(startdate) And CDate(ExpectedBookDate)<CDate(Enddate)

try as below
CDate(cstr(ExpectedBookDate))>CDate(cstr(startdate)) And CDate(cstr(ExpectedBookDate))<CDate(cstr(Enddate))

Not Needed @Vaishnav_Tej

It’s working fine at my end.


No errors but it’s going to Else part


Sequence: Can not assign ‘DateTime.ParseExact(ExpectedBookDate, “MM/dd/yyyy”, System.Globalization.CultureInfo.InvariantCulture)’ to ‘expectedDate’.

I’m getting these error.

Can you send the workflow


Sequence13.xaml (10.9 KB)

Hope it helps!!