hi there,
i am trying to get a textBox.text to show the WEEK NUMBER OF YEAR as at the datetime.now how can i do this
this is the code i am using to show the date AND time.
textBox.text = Datetime.Now.ToString();
any help??
Answers (2)
1
It depends exactly what you mean by 'week number of year' but, taking the first week as 1 Jan to 7 Jan, the second week as 8 Jan to 14 Jan and so on, then the following should work:
DateTime today = DateTime.Today;
DateTime start = new DateTime(today.Year, 1, 1);
int weekOfYear = (today - start).Days/7 + 1;
textBox.Text = weekOfYear.ToString();
Accepted 0
THANKS ALOT VULPES IT WORKED JUST LIKE NEEDED.
BEST REGARDS