473,406 Members | 2,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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.
Mar 9 '08 #1
2 7460
"Mike" <Mi**@discussions.microsoft.comschrieb:
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/>

Mar 9 '08 #2
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" <Mi**@discussions.microsoft.comschrieb:
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/>

Mar 10 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: John Bentley | last post by:
John Bentley: INTRO The phrase "decimal number" within a programming context is ambiguous. It could refer to the decimal datatype or the related but separate concept of a generic decimal number....
4
by: Stewart Allen | last post by:
I'm trying to filter a table that has 2 date fields, the first date will always have a value but the second will only occasionally has a value. Each date field also has a corresponding text field...
2
by: Mary | last post by:
I am trying to develop a query which will determine the average costs using a rolling average of the past 12 months of data. In other words, if I entered the Ship Month of January and the Ship...
12
by: Steve Elliott | last post by:
I have a query set up to gather together data between two specified dates. Shown in the query column as: Between #24/09/2004# And #01/10/2004# Is it possible to enter several different date...
6
by: alexanderpope11 | last post by:
Hello, how do I write this SQL: I would like to check the Main table for invalid rows. An invalid row is: any row where the Start_date to stop_date range overlaps an invalid date in the Code...
18
by: dfetrow410 | last post by:
Anyone have some code that will do this? Dave
13
by: Jim Armstrong | last post by:
Hi all - This problem has been driving me crazy, and I'm hoping the answer is something stupid I am neglecting to see.... The procedure posted below is part of an Access/SQL database I have...
4
Sandboxer
by: Sandboxer | last post by:
I want to be able to program Access to provide for me, by individual day, what my contract obligations are to my customers. Will Access recognize all the individual days in between a date range...
2
by: shannonwhitty | last post by:
I am able to extract dates in the correct format i.e. SELECT CONVERT(VARCHAR(8), GETDATE(), 3) =dd/mm/yy My issue is that my users are selecting a date in this format and I need to select...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.