Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# groupby date

yourDateList.GroupBy(i => i.ToString("yyyyMMdd"))
             .Select(i => new
             {
                 Date = DateTime.ParseExact(i.Key, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None),
                 Count = i.Count()
             });
Comment

c# groupby date


context.Users
    .Where((x.LastLogIn  >= lastWeek) && (x.LastLogIn <= DateTime.Now))
    .GroupBy(x => DbFunctions.TruncateTime(x.LastLogIn))
    .Select(x => new
    {
        Value = x.Count(),
        // Replace the commented line
        //Day = (DateTime)DbFunctions.TruncateTime(x.Key)
        // ...with this line
        Day = (DateTime)x.Key
    }).ToList();

Comment

PREVIOUS NEXT
Code Example
Csharp :: .net core check if user is logged in 
Csharp :: c# difference between two dates in milliseconds C# 
Csharp :: print array in c# 
Csharp :: weighted random c# 
Csharp :: unity point between two positions 
Csharp :: stop a thread c# 
Csharp :: c# find duplicates in list of strings 
Csharp :: How do i destroy a prefab without the error? 
Csharp :: unity rotation 
Csharp :: c# write byte[] to stream 
Csharp :: wpf set color in code 
Csharp :: change sprite of a sprite unity 
Csharp :: error provider c# 
Csharp :: c# console foreground color 
Csharp :: linux command line switch statement 
Csharp :: c# do while loop 
Csharp :: make a list c# 
Csharp :: c# remove double quotes from string 
Csharp :: check if animation is playing unity 
Csharp :: c# initialize empty array 
Csharp :: c# color hex 
Csharp :: c# find all indexes 
Csharp :: exit button unity code 
Csharp :: selection sort in c# 
Csharp :: c# datetime add 
Csharp :: how to generate random number in unity 
Csharp :: how to convert float to int c# 
Csharp :: string list to object array in c# 
Csharp :: c# input 
Csharp :: c# list audio devices 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =