I've done in console app, everything is works properly and I apply this code to my previous code, it works properly. Anyway thanks.
Below is the example of the code.
static void Main(string[] args)
{
DataTable dtDataResult = new DataTable();
DataColumn dcDataResult = dtDataResult.Columns.Add("DateTime", typeof(DateTime));
dcDataResult = dtDataResult.Columns.Add("Count", typeof(Int16));
DateTime DateStart = Convert.ToDateTime("9/1/2023 2:00:00");
DateTime DateEnd = DateStart + TimeSpan.FromMinutes(59);
for (int intCount = 0; intCount < 8; intCount++)
{
int intTest = 0;
TimeSpan tsGetHours = DateEnd - DateStart;
for (int intDataRow=0; intDataRow< 10; intDataRow++)
{
intTest++;
}
DataRow dtDataRowResult = dtDataResult.NewRow();
dtDataRowResult[0] = DateStart;
dtDataRowResult[1] = intTest;
dtDataResult.Rows.Add(dtDataRowResult);
DateStart = DateStart.AddHours(1);
DateEnd = DateStart + TimeSpan.FromMinutes(59);
}
}
below is the screenshot image of the code.