I know you mentioned VB, but here's a C# example.
Basiclly you just need to get the Day of the Week and substract where you're
at in the Day of the Week and pass that to AddDays() (AddDays() accepts
negative numbers) and that'll get you to your start of the week (Sunday).
class Class1
{
static DateTime AheadWeek(DateTime dt, int numOfWeeks)
{
return(dt.AddDays( ( -(Convert.ToInt32(dt.DayOfWeek)) ) + (numOfWeeks *
7) ));
}
[STAThread]
static void Main(string[] args)
{
// Start of this week
DateTime dt = AheadWeek(DateTime.Now, 0);
// One week ahead of todays date
DateTime dt = AheadWeek(DateTime.Now, 1);
// Two weeks ahead of todays date
DateTime dt = AheadWeek(DateTime.Now, 2);
}
}
"Adam" <ad**@blah.com> wrote in message
news:y2********************@news20.bellglobal.com. ..
Hello,
How to find a last day of the next week (or in next two weeks) using
VB.NET?
for example:
01-Feb-2005 = 13-Feb-2005
or
09-May-2005 = 22-May-2005
Any help is greatly appreciated,
Adam