VB.NET boolean if date is between start and end date

Hi, how do I write the Boolean expression in VB.NET for whether a date is within start and end date?

If ((dTableDate >= dFromDate) And (dTableDate <= dToDate)) Then
    Console.WriteLine("between")
Else
    Console.WriteLine("not between")
End If
1 Like

You can do something like this

mailDate = cDate(item.Headers("Date")) where item is a mailMessage

This will give you the date of the email, then you can use if condition and write something like this

if (mailDate < DateTime.Now AND mailDate > DateTime.Now.AddHours(-1))
{ then do your stuff}

This is just a sample. You can manipulate in your own way.

i think you are confused with another thread, this is not email related :slight_smile:

2 Likes

@bcorrea
:grin:
This is just a sample. You can manipulate in your own way.

I think @anmolk171 was just giving the context to the example. If you look at what the script does it makes sense. He’s just assuming the date you want to be between the start and end date is the receive date of an email or something.

1 Like

@mike.vansickle - Exactly buddy :grinning::smiley: