need some DateTime help
-
sorry, cant get my brain working this morning. the logical question I need my program to figure out is : The X day of every Y month(s) with a Startdate of Z and a (Enddate of W OR occur V times) this is my start:
string matchpattern2 = "(0[1-9]|[12][0-9]|2[08])"; Regex re2 = new Regex(matchpattern2); if(re2.Match(monthly1TxtBox1.Text.ToString()).Success == true) { int intDays = 0; TimeSpan tsWeekly = endDateTime.Date.Subtract(startDateTime); intDays = tsWeekly.Days; DateTime[] datearray = new DateTime[intDays]; for(int x=0; x anyone experienced with doing something like this? -- modified at 9:06 Tuesday 20th December, 2005
-
sorry, cant get my brain working this morning. the logical question I need my program to figure out is : The X day of every Y month(s) with a Startdate of Z and a (Enddate of W OR occur V times) this is my start:
string matchpattern2 = "(0[1-9]|[12][0-9]|2[08])"; Regex re2 = new Regex(matchpattern2); if(re2.Match(monthly1TxtBox1.Text.ToString()).Success == true) { int intDays = 0; TimeSpan tsWeekly = endDateTime.Date.Subtract(startDateTime); intDays = tsWeekly.Days; DateTime[] datearray = new DateTime[intDays]; for(int x=0; x anyone experienced with doing something like this? -- modified at 9:06 Tuesday 20th December, 2005
What are you trying to do? Skimming over your code (use pre tags next time), I can't make out from your code what you're trying to accomplish.
-
sorry, cant get my brain working this morning. the logical question I need my program to figure out is : The X day of every Y month(s) with a Startdate of Z and a (Enddate of W OR occur V times) this is my start:
string matchpattern2 = "(0[1-9]|[12][0-9]|2[08])"; Regex re2 = new Regex(matchpattern2); if(re2.Match(monthly1TxtBox1.Text.ToString()).Success == true) { int intDays = 0; TimeSpan tsWeekly = endDateTime.Date.Subtract(startDateTime); intDays = tsWeekly.Days; DateTime[] datearray = new DateTime[intDays]; for(int x=0; x anyone experienced with doing something like this? -- modified at 9:06 Tuesday 20th December, 2005
Joshua Lunsford wrote:
string matchpattern2 = "(0[1-9]|[12][0-9]|2[08])";
I am not quite sure what your regular expression is supposed to match on. 0[1-9] matches 01 through 09. [12][0-9] matches 10 through 29. 2[08] matches 20 or 28. This is already covered by previous. Do you want it to be 3[0-8] Also, as it is, this RE will match number in a larger string. For instance, the following string will match on the 20: 34562055 If you only want two characters, try:
(^0[1-9]|[12][0-9]|2[08]$)
Roy. -
Joshua Lunsford wrote:
string matchpattern2 = "(0[1-9]|[12][0-9]|2[08])";
I am not quite sure what your regular expression is supposed to match on. 0[1-9] matches 01 through 09. [12][0-9] matches 10 through 29. 2[08] matches 20 or 28. This is already covered by previous. Do you want it to be 3[0-8] Also, as it is, this RE will match number in a larger string. For instance, the following string will match on the 20: 34562055 If you only want two characters, try:
(^0[1-9]|[12][0-9]|2[08]$)
Roy.i want it to match on 1-28
-
What are you trying to do? Skimming over your code (use pre tags next time), I can't make out from your code what you're trying to accomplish.
Judah Himango wrote:
What are you trying to do?
On the X day of every Y month(s) with a Startdate of Z and a (Enddate of W OR occur V times) i want to doSomeWork()
Judah Himango wrote:
I can't make out from your code what you're trying to accomplish.
sorry, basically all i've done so far(in the code i posted) is make an array of DateTime's between the start and end date.
-
Judah Himango wrote:
What are you trying to do?
On the X day of every Y month(s) with a Startdate of Z and a (Enddate of W OR occur V times) i want to doSomeWork()
Judah Himango wrote:
I can't make out from your code what you're trying to accomplish.
sorry, basically all i've done so far(in the code i posted) is make an array of DateTime's between the start and end date.
= startDateTime.AddDays(x); } Array.Sort(datearray); int loopcounter = 0; int intRecur = 0; if(occTxtBox.Text.Length > 0) intRecur = Int32.Parse(occTxtBox.Text.ToString()); int occurNum = 0; for(int x=0;x < intDays;x++) { if(intRecur == 0) { if(datearray[x].Day == dayOfMonth) { if(loopcounter == 0) { //DoWork loopcounter = loopcounter + iterativeMonths+1; } else if(datearray[x].Month == startDateTime.AddMonths(loopcounter).Month) { //DoWork loopcounter = loopcounter + iterativeMonths; } } } else { if(datearray[x].Day == dayOfMonth && occurNum < intRecur) { if(loopcounter == 0) { //DoWork loopcounter = loopcounter + iterativeMonths+1; occurNum++; } else if(datearray[x].Month == startDateTime.AddMonths(loopcounter).Month) { //DoWork loopcounter = loopcounter + iterativeMonths; occurNum++; } } } } msg.Text += "Task Added"; posAddEdit = 0; } else { msg.Text = "Please enter a day between 1 & 28"; } p.s. pre /pre always eats my for loops -- modified at 18:23 Wednesday 21st December, 2005 -
i want it to match on 1-28