Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

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;
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: unity switch 
Csharp :: unity text custom color 
Csharp :: c# object list attribute to string 
Csharp :: get all components of type unity 
Csharp :: c# replace dash in string 
Csharp :: how to get type of an object in c# 
Csharp :: c# binding add combobox with enum values 
Csharp :: unity create 3d object in script 
Csharp :: c# char 
Csharp :: checking if a list contains a value unity 
Csharp :: c# get type of class 
Csharp :: get file path in .net core from wwwroot folder 
Csharp :: how to acivate a game object unity 
Csharp :: c# array max 
Csharp :: group by ef core 
Csharp :: how to get current dir in c# 
Csharp :: how to locate a specific element in a list c# 
Csharp :: pyautopgui wrros on big sur 
Csharp :: c# clear an array 
Csharp :: map user to ConnectionId SignalR 
Csharp :: unity convert number to notation 
Csharp :: input field to float unity 
Csharp :: autofac .net core 6 
Csharp :: c# count directories in directory and subdirectories 
Csharp :: c# make file writable 
Csharp :: c# show list in richtextbox 
Csharp :: what is list in c# 
Csharp :: ignore ssl c# 
Csharp :: C# max rand 
Csharp :: searching for keys in the registry 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =