Hi Guys,
Is there a way to get the week number of the year from a datetime picker value and display the number on a label, label1 for instance?
As an example, if I was to select todays date, in theory it would display '26' on my label.
Can that be done? I know datetime pickers can display number of day, but not week for some reason.

mike DelvottiRank #7,298 · 244 reputationPosted Jun 26, 2015, 8:03 AM EDT
Thanks, I ended up using the below from your answer:
CalendarWeekRule weekRule = CalendarWeekRule.FirstFourDayWeek;
Calendar calendar = System.Threading.Thread.CurrentThread.CurrentCulture.Calendar;
int currentWeek = calendar.GetWeekOfYear(dateTimePicker1.Value, weekRule, firstWeekDay);
label1.Text = String.Format("{1:00}", dateTimePicker1.Value, currentWeek);
Ramesh MaruthiRank #937 · 2.2K reputationPosted Jun 26, 2015, 8:16 AM EDT
Ramesh MaruthiRank #937 · 2.2K reputationPosted Jun 25, 2015, 11:07 AM EDT
onSelect: function (dateText, inst) {
$('#weekNumber').val($.datepicker.iso8601Week(new Date(dateText)));
}
});
mike DelvottiRank #7,298 · 244 reputationPosted Jun 26, 2015, 12:39 AM EDT
Hi, Thanks for reply.
Sorry I should of mentioned that I'm using C# in Windows forms application.
Rajeesh MenothRank #118 · 18.4K reputationPosted Jun 26, 2015, 12:46 AM EDT
Ramesh MaruthiRank #937 · 2.2K reputationPosted Jun 26, 2015, 5:26 AM EDT