Click here to Skip to main content
15,903,012 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to get week numbers from selected date range (from 2 date pickers) in vb.net.

Example: the start date is
01/Jul/2015
and the end date is
15/Aug/2015

With this date range there are total 7 weeks start from week 27 to week 33.

How to get these weeks in data grid view?
Posted
Updated 30-Sep-15 23:56pm
v6

You can use the Calendar.GetWeekOfYear Method:

VB
'Declaration
Public Overridable Function GetWeekOfYear ( _
	time As DateTime, _
	rule As CalendarWeekRule, _
	firstDayOfWeek As DayOfWeek _
) As Integer
 
Share this answer
 
v2
Comments
ShivAkshay 1-Oct-15 6:35am    
I know how to Getting week number. but I want it in looping. The date range available in data base. I want convert all selected date range in week number & populate in datagridview.
Ralf Meier 1-Oct-15 6:50am    
There is no automatic function availible for this.
You have to fill in the data into your dgv and after this you calculate for each row the Week-Value and put it into the wanted cell ...
There is an article on this site;

ExtendedDateTimePicker control with week numbers[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900