|
-
Aug 18th, 2008, 05:45 AM
#1
Thread Starter
Hyperactive Member
[02/03] Skipping Dates
Hello everyone.
I need to determine if a dynamic date is in a specified date range.
For example, I have 1 initial start date, then during the cours of the application, I add x amount of weeks / x amount of months to it, until it reaches the specified end date. - This all works fine.
What I have to do now, is to compensate for a 3 week leave period ( the last 2 weeks of dec and the first week of jan ). because of the 3 week break period, I need to add the "extra" 3 weeks to the current dynamic date in that range.
Can anyone please give me an idea, perhaps example on how I should go about doing this?
I'm alread using DateAdd to add the weeks / months. What I'm battling with is to determine the 3 weeks leave period.
For example, say I have been adding the dates and everything goes well.
Let us also realise that the 3 week break period starts the 15th december ( which may differ depending on input).
So now, after I have added the date, and I see that this date is between 15 december and 5 january, I have to add an additional 3 weeks to it,
how would I do this?
Thank you.
-
Aug 18th, 2008, 06:44 AM
#2
Re: [02/03] Skipping Dates
Don't use DataAdd in VB.NET.
vb.net Code:
Dim myDate As Date = Date.Today 'Add a week. myDate = myDate.AddDays(7) 'Add a month. myDate = myDate.AddMonths(1) If (myDate.Month = 12 AndAlso myDate.Day >= 15) OrElse _ (myDate.Month = 1 AndAlso myDate.Day <= 5) Then myDate = myDate.AddDays(21) End If
You could use Date literals at the end there but the way I've done it will work for any year. You can also use variables for the days of December and January if they will vary.
-
Aug 18th, 2008, 07:23 AM
#3
Thread Starter
Hyperactive Member
Re: [02/03] Skipping Dates
Thank you sir, I'll give that a try
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|