get what week of the month c#
static int GetWeekNumberOfMonth(DateTime date)
{
date = date.Date;
DateTime firstMonthDay = new DateTime(date.Year, date.Month, 1);
DateTime firstMonthMonday = firstMonthDay.AddDays((DayOfWeek.Monday + 7 - firstMonthDay.DayOfWeek) % 7);
if (firstMonthMonday > date)
{
firstMonthDay = firstMonthDay.AddMonths(-1);
firstMonthMonday = firstMonthDay.AddDays((DayOfWeek.Monday + 7 - firstMonthDay.DayOfWeek) % 7);
}
return (date - firstMonthMonday).Days / 7 + 1;
}
Also in C#:
- switch case c# contains
- c# changimg to one decimal place
- change textbox location C#
- nunit return parameter
- how to add to a list c#
- Microsoft.AspNetCore.Components.Forms.InputSelect`1.TryParseValueFromString(String value, TValue& result, String& validationErrorMessage)
- use enter key unity
- asp.net core task iactionresult
- multidimensional meaning
- c# ref
- download file from url asp net web api c#
- asp.net core 3.1: cast jObject to dictionary<string,string>
- c# change colour of console
- create object in c#
- get what week of the month c#
- change Backcolor c#
- c# how to add newline on text box
- prefab gets character transform
- c# function
- c# access session in class
- c# string to memorystream
- c# delegate return value invoke
- c# build string out of list of strings
- unity separator in inspector