PDA

View Full Version : Compare dates of different years



Student1000
05-18-2010, 09:37 AM
Hey everybody,
I have the following problem with my travel agency VBA program:
the user can indicate his arrival and departure date via a pop up calendar.
However, I have to compare the data the user entered with the data in my Database (we are talking about ski resorts opening seasons). This means, I need to check whether the dates the user entered (arrival and departure) lie within the season of a respective ski resort. However, I saved the ski resort Season data in the format dd.mm.2010. The problem is that the duration of a ski season is spread over 2 consecutive years.

If I assume that the season start and ending dates never change, can anyone tell me how i can check whether the arrival and departure date the user entered correspond with the season dates (especially because i have different years e.b. 2010/11, 2011/12, 2012/13). The value in the calculation sheet should be 1 if the dates of the user are within a season and 0 otherwise.

thanks for any help in advance!

lynnnow
05-18-2010, 09:41 AM
Would this be of any help? http://www.vbaexpress.com/kb/getarticle.php?kb_id=1056

Student1000
05-18-2010, 09:47 AM
Would this be of any help? http://www.vbaexpress.com/kb/getarticle.php?kb_id=1056

Well the problem I actually have is that the season in my database should be continuous. currently the season dates are saved for the year 2010. If, however, the user enters a date for 2011 my calculations will not work.

So what I need:
How to tell excel, that the date entered by the user in my VBA GUI should be matched with only to the DAY and MONTH of the season as stored in my excel Database. (the special thing is also that a ski season usually lasts from the end of one year to the beginning of the next. e.g. 11/01/2010 till 03/20/2011)

could you maybe help me with that?
thx

Bob Phillips
05-18-2010, 10:17 AM
Why don't you start by putting the start date in the correct year, such as 05/12/2009 rather than 05/12/2010. Comparison is then easy because Excel stores dates as simple numbers, so 31/04/2010 is bigger than 05/12/2009.

Student1000
05-18-2010, 11:15 AM
Well first of all sorry for not putting the right dates in the excel sheet. of course it should read 2010 for start and 2011 for end of the respective seasons.

However, if the user books his ski trip for the year 2013 for instance, the database will not provide any matching seasons. So How can I make the date range of the seasons independent of a specific year?

cheers

Bob Phillips
05-18-2010, 11:25 AM
Where is the data input, all I could see was a grey blob.

Student1000
05-18-2010, 12:13 PM
Its in D23 and D24 in the User Data Sheet.. I had to delete the other data since they are confidential.
sorry for the confusion!