|
|
|
รบกวนช่วยแนะนำวิธี Split แถวจากผลรวมจำนวนวันด้วยค่ะ |
|
|
|
|
|
|
|
เขียนสดนะ ผิดถูกขออภัย
Code (C#)
string exam = "4 30/01/2012 02/02/2012";
string[] split = exam.Splite((" ").ToCharArray());
int dayCount = Convert.ToInt32(split[0]);
DateTime minDate = Convert.ToDateTime(split[1], new System.Globalization.CultureInfo("en-GB"));
DateTime maxDate = Convert.ToDateTime(split[2], new System.Globalization.CultureInfo("en-GB"));
Enumerable.Range(0, dayCount).Select(d => minDate.AddDays(d)).ToList().ForEach(d => {
Console.Write(d.ToString("dd MMMM yyyy", new System.Globalization.CultureInfo("en-GB")));
});
|
|
|
|
|
Date :
2012-06-25 16:31:58 |
By :
อิอิ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
อิอิ ผิดๆ แก้ๆ
Code (C#)
string[] split = exam.Split((" ").ToCharArray());
|
|
|
|
|
Date :
2012-06-25 16:34:37 |
By :
อิอิ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
หา countDate จาก maxDate ก็ได้นะ
Code (C#)
int dayCount = 1 + (int)(maxDate - minDate).TotalDays;
|
|
|
|
|
Date :
2012-06-25 16:38:25 |
By :
อิอิ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (C#)
DateTime FromDate = new DateTime(2012, 01, 30);
DateTime ToDate = new DateTime(2012, 02, 02);
TimeSpan ts = ToDate - FromDate;
for (int i = 1; i <= ts.Days; i++)
{
FromDate.AddDays(ts.Days);
}
แบบนี้หรือป่าว
|
|
|
|
|
Date :
2012-06-25 17:07:15 |
By :
kanchen |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|