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.
Ramesh MaruthiPosted Jun 26, 2015, 12:16 PM
mike DelvottiPosted Jun 26, 2015, 12:03 PM
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 MaruthiPosted Jun 26, 2015, 9:26 AM
Rajeesh MenothPosted Jun 26, 2015, 4:46 AM
mike DelvottiPosted Jun 26, 2015, 4:39 AM
Hi, Thanks for reply.
Sorry I should of mentioned that I'm using C# in Windows forms application.
Ramesh MaruthiPosted Jun 25, 2015, 3:07 PM
onSelect: function (dateText, inst) {
$('#weekNumber').val($.datepicker.iso8601Week(new Date(dateText)));
}
});