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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Next xxxxxDay - Date Manipulation

Status
Not open for further replies.

mdjoin

Programmer
Jun 22, 2007
9
US
Hey guys,

I've searched and found several ways of doing this, but I am trying to see if there is a way to avoid doing this with a loop.

What I need to do, is autopopulate a textbox with next Friday's date. No matter what day I land on.

I know you can do this with a simple while loop and DayOfWeek, but I was hoping to find a much smaller solution, mainly because I'm interested in it.

Anyone have any ideas on another way to find the next say, Friday from any day of the week that doesn't involve a loop?

Thanks,
 
Ignore this post, I found a way to do it.

Dim nextFriday As DateTime = System.DateTime.Today()
If System.DateTime.Today.DayOfWeek <> DayOfWeek.Friday Then
Dim dayCount As Integer = System.DateTime.Today.DayOfWeek
dayCount = System.DayOfWeek.Friday - dayCount
txtNextFriday.Text = System.DateTime.Today.AddDays(dayCount)
End If

Works like a charm.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top