Determine if a Date is BETWEEN a date range.

M

Mike

Hi. In my VB.NET application I need to identify whether or not a user-input
date falls in between certain date ranges. For example, If I know my date
range is 4/1/2008 - 5/1/2008, and a user inputs 4/3/2008, I would need a
boolean TRUE indicating that the input date falls between date ranges.

I know I could do greater than/less than comparisons, but I want to check if
there's a simpler way to accomplish this.

Thank you.
 
H

Herfried K. Wagner [MVP]

Mike said:
Hi. In my VB.NET application I need to identify whether or not a
user-input
date falls in between certain date ranges. For example, If I know my
date
range is 4/1/2008 - 5/1/2008, and a user inputs 4/3/2008, I would need a
boolean TRUE indicating that the input date falls between date ranges.

\\\
Dim d As Date = Date.ParseExact(...)
Dim IsDateInRange As Boolean = _
(d >= #4/1/2008# AndAlso d <= #4/3/2008#)
///
I know I could do greater than/less than comparisons,
but I want to check if there's a simpler way to accomplish
this.

I don't see why this way is not simple enough.
 
S

SurturZ

Using greater than & less than is only one line of code, how much simpler can
it get??

--
David Streeter
Synchrotech Software
Sydney Australia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top