Home > Net >  C # two time in a month for differential space, less than a month and do the processing
C # two time in a month for differential space, less than a month and do the processing

Time:09-16

Because when product demand is not clear, will lead to a group of old data imported into the new table, but had some trouble, specific as follows
A so A user data, for example, the start time and end time is respectively
The 2020-4-16 10:05:23-2020-4-16 8:05:23

I want to send this period data by month as the time unit is divided into several parts, less than one month alone for 1 the data
For example,
The 2020-4-16 10:05:23-2020-4-16 10:05:23
The 2020-5-16 10:05:23-2020-5-16 10:05:23
The 2020-6-16 10:05:23-2020-6-16 10:05:23
The 2020-7-16 10:05:23-2020-7-16 10:05:23
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Here omit
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
The 2020-11-16 10:05:23-2020-11-16 10:05:23
2020-12-16 10:05:23-2020-12-16 8:05:23 last 1 because they do not meet a month to do this

Excuse me this how to implement, the key is the last article data



CodePudding user response:

According to big though moral emperor supreme instructions, we just put a piece of code, you can read, can't read don't read the query yield return why, what is the meaning of Aggregate, (or large though moral emperor again that we despise, hit the newcomer, doubt new intelligence, let the couple to read)

 static void Main (string [] args) 
{

DateTime start=DateTime. Parse (" the 2020-4-16 10:05:23 ");
DateTime end=DateTime. Parse (" the 2021-1-15 8:05:23 ");

Var list=spliteByMonth (start, end). Aggregate ((d1, d2)=& gt;
{
Console. WriteLine (${d1} \ "t {d2}");
Return d2.
});

Console.ReadKey();
}

The static IEnumerable SpliteByMonth (DateTime start, DateTime end)
{
Yield return start;

While (true)
{
Start=start. AddMonths (1);
If (start & lt; End)
Yield return start;
The else
break;

}

Yield return end;

}

CodePudding user response:

Can write such
Nuget System. Reactive
reference
DateTime start=DateTime. Parse (" the 2020-4-16 10:05:23 ");
DateTime end=DateTime. Parse (" the 2021-1-15 8:05:23 ");

Observables. Create (obs=& gt;
{
Obs. OnNext (start);
While (true)
{
Start=start. AddMonths (1);
If (start & lt; End)
Obs. OnNext (start);
The else
break;
}
Obs. OnNext (end);
Obs. OnCompleted ();
Return ()=& gt; {};
})
Buffer (2, 1). The Where (p=& gt; P.C mount==2)
The Subscribe (async p=& gt;
{
Console. WriteLine (string. Join (" - ", p));
});


According to the same big though moral emperor supreme instructions, do you understand it, don't understand, I can't say that please see the response of concurrent Programming c # Programming (Reactive Programming), because of the large though moral emperor would say we despise, haze people don't understand what is concurrent Reactive Programming

CodePudding user response:

According to the same big though moral emperor supreme instructions, we can't tell you that the above two except with something different, they all belong to the same paradigm graphs (map map Reduce reduction), because it will despise you have no culture,

Also I can't tell you, based on this model, if your project of the great amount of data, you can use a spark to do distributed computing to improve performance, because it is obvious that you are a loster, don not worthy shall have the right to use the spark

CodePudding user response:

reference wanghui0380 reply: 3/f
according to the same big though



What is this thing

CodePudding user response:

reference 4 floor by_ love reply:
Quote: reference wanghui0380 reply: 3/f

According to the same big though



What is this thing

This is stems from https://bbs.csdn.net/topics/396280201
The comments section guild wars

CodePudding user response:

Big though moral emperor??????
  •  Tags:  
  • C#
  • Related