Date within a Range of Dates 
Author Message
 Date within a Range of Dates

Jeez, between this newsgroup and the FAQs, the Tips and Tricks and the
Knowledge Base, I'm learning VB at an exponential rate!  Damn, I love a
language with a lot of support!!!

OK, this problem probably has a simple solution that's escaping me.  I
have 3 variables: AppointmentDate (type 7 variant), DaysBefore (integer)
and DaysAfter (integer).  I need to determine if a user-specified date
falls within a date range specified by AppointmentDate-DaysBefore and
AppointmentDate+DaysAfter.

I assumed VB records its dates as a serial number, like Microsoft Works,
but it looks like I'm wrong.  Does anyone have a solution or suggestion
to help me solve this problem?

Many thanks, once again, to all who offer their help!

Paul



Sun, 23 Nov 1997 03:00:00 GMT  
 Date within a Range of Dates

Quote:
>OK, this problem probably has a simple solution that's escaping me.  I
>have 3 variables: AppointmentDate (type 7 variant), DaysBefore (integer)
>and DaysAfter (integer).  I need to determine if a user-specified date
>falls within a date range specified by AppointmentDate-DaysBefore and
>AppointmentDate+DaysAfter.

Paul, check out Help on DateAdd.  Very handy.  Note that it requires
another dll in your distribution though (it's the Financial Functions one.  
Maybe MSAFINX or something like that.)

Welcome to VB.  Whips hell out of assembly.
--

Systems Analyst         WWW:    http://www.phoenix.net/USERS/getj



Mon, 24 Nov 1997 03:00:00 GMT  
 Date within a Range of Dates

Quote:
>OK, this problem probably has a simple solution that's escaping me.  I
>have 3 variables: AppointmentDate (type 7 variant), DaysBefore (integer)
>and DaysAfter (integer).  I need to determine if a user-specified date
>falls within a date range specified by AppointmentDate-DaysBefore and
>AppointmentDate+DaysAfter.

>I assumed VB records its dates as a serial number, like Microsoft Works,
>but it looks like I'm wrong.  Does anyone have a solution or suggestion

In ALL date related queries, I always convert the date to julian and work
from there.  Just grab you a share snipit of code that converts a date to
a julian date and you'll be home free.  I have Pascal source, maybe even
basic source if you need it.

PsuedoCode:

DateToCheck$="01/01/94"
DaysBefore = 10
DaysAfter = 20
InPutDate$ = "02/02/95"

DateToCheckJulian = Date2Julian(DateToCheck$)
InputDateJulian = Date2Julian(InPutDate$)

If DateToCheckJulian - DaysBefore >= InputDateJulian and
   DateToCheckJulian + DaysAfter <= InputDateJulian then
   "InputDate$" is within the range.

I wrote this on the fly, and didn't really check my pluses and minuses
but in essence, you see how it works.  Plus, julian dates NEVER lie.



Tue, 25 Nov 1997 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Crystal Reports 8.5 date range parameter field - record selection that includes null date range

2. Calculate no of days in a month within a specified date range

3. Filter for actual work within specific date range

4. Selecting records within date range

5. Create Date array using Date range

6. date range to current date at specific time syntax question

7. Q:get current date and then create date range

8. Date - date = date

9. Compare date in form with date/time in form with date/time in database

10. Dates dates dates

11. Dates, Dates, & More Dates

12. VBA COntrolled Date Range in SQL Query

 

 
Powered by phpBB® Forum Software