Determine if a Date is BETWEEN a date range.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?TWlrZQ==?=

    #1

    Determine if a Date is BETWEEN a date range.

    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.
  • Herfried K. Wagner [MVP]

    #2
    Re: Determine if a Date is BETWEEN a date range.

    "Mike" <Mike@discussio ns.microsoft.co mschrieb:
    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.

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

    Comment

    • =?Utf-8?B?U3VydHVyWg==?=

      #3
      Re: Determine if a Date is BETWEEN a date range.

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

      --
      David Streeter
      Synchrotech Software
      Sydney Australia


      "Herfried K. Wagner [MVP]" wrote:
      "Mike" <Mike@discussio ns.microsoft.co mschrieb:
      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.
      >
      --
      M S Herfried K. Wagner
      M V P <URL:http://dotnet.mvps.org/>
      V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
      >
      >

      Comment

      Working...