Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DateTime recurrence pattern

Status
Not open for further replies.

kettch

Programmer
Mar 5, 2001
110
US
Part of the application I'm working on requires scheduling function that is similar to the outlook meeting scheduler. It lets you schedule something for every x weeks on x days.

The problem that I am having is figuring out how to actually map those selections to specific dates. What would be the best way to find "next monday" or "next week on tuesday, wednesday and friday"?

I've fiddled around with it but can't seem to figure out anything concrete.

Any suggestions?

-Thanks
 
Try DateDiff()

Maybe this world is another planet’s Hell.
Aldous Huxley
 
Finding next Monday
Code:
Dim x As Date = Date.Today
While x.DayOfWeek() <> DayOfWeek.Monday
    x = x.AddDays(1)
End While


Sweep
...if it works dont f*** with it
...if its f****ed blame someone else
...if its your fault that its f***ed, say and admit nothing.
 
I ended up using a loop, but it's a bit more complicated. The loop SquakinSweep provided is basically the one I came up with first. But because I had to use my own custom DayOfWeek enumeration (the default one isn't flagged) I had to do some juggling to get the custom one, and the one datetime uses to synch.

DateDiff won't work because I at runtime I only know the start date and all I know about the event date is that it is "the tuesday after next".

Thanks for all your help everybody
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top