Solved

vb.net DatePicker default to beginning and end of week

Posted on 2009-05-08
3
464 Views
Last Modified: 2012-05-06
I had created a VB.Net windows form.  I would like to use 2 datepicker as a search.  However, I would like the default value from first datepicker to be beginning date of week and datepicker2 to be ending date of week.

So example would be something like:
Monday - Sunday  -->  5/4/2009 - 5/10/2009
Monday - Sunday  -->  5/11/2009 - 5/17/2009
etc.

Can anyone help with this by sending my form_load to have these default date range for the datepicker control?
0
Comment
Question by:holemania
3 Comments
 
LVL 33

Expert Comment

by:jppinto
ID: 24339988
0
 
LVL 3

Accepted Solution

by:
xbrady earned 500 total points
ID: 24340050
dateTimePickerFirstDayOfWeek.Value = DateTime.Now.AddDays(-1 * CInt(DateTime.Now.DayOfWeek))
dateTimePickerLastDayOfWeek.Value = DateTime.Now.AddDays(6 - CInt(DateTime.Now.DayOfWeek))
0
 

Author Closing Comment

by:holemania
ID: 31579633
Awesome.  That's what I wanted
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now