kensy11
asked on
Count days of the month
Hello,
i have just made a simple program it ask for a date and it cheks for a leap year,
the second thing i like this program to do is, to show the day number in the given date. so for example if the given date is 10/1/2010 i should say the date is its the 10th day day of the year ...
but i dont know how to do this anyone help me please??
i have upload the program.
thank you
ConsAppl1TI24.zip
i have just made a simple program it ask for a date and it cheks for a leap year,
the second thing i like this program to do is, to show the day number in the given date. so for example if the given date is 10/1/2010 i should say the date is its the 10th day day of the year ...
but i dont know how to do this anyone help me please??
i have upload the program.
thank you
ConsAppl1TI24.zip
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks , but how can i dot it manually i mean without the DateTime property
ASKER
something like this??
ushort totaal;
ushort m1 = 31;
ushort m2 = 28;
ushort m3 = 31;
ushort m4 = 30;
ushort m5 = 31;
ushort m6 = 30;
ushort m7 = 31;
ushort m8 = 31;
ushort m9 = 30;
ushort m10 = 31;
ushort m11 = 30;
ushort m12 = 31;
switch (Maand) {
case 1:
totaal += m1;
break;
case 2:
totaal +=(m1+m2);
if(ctrl.Jaar(jaar))
totaal +=1;
break;
case 3:
totaal +=(m1+m2+m3);
if(ctrl.Jaar(jaar))
totaal +=1;
break;
case 4:
totaal +=(m1+m2+m3+m4);
if(ctrl.Jaar(jaar))
totaal +=1;
break;
case 5:
totaal +=(m1+m2+m3+m4+m5);
if(ctrl.Jaar(jaar))
totaal +=1;
break;
case 6:
totaal +=(m1+m2+m3+m4+m5+m6);
if(ctrl.Jaar(jaar))
totaal +=1;
break;
case 7:
totaal +=(m1+m2+m3+m4+m5+m6+m7);
if(ctrl.Jaar(jaar))
totaal +=1;
break;
case 8:
totaal +=(1+2+3+4+m5+m6+m7+m8);
if(ctrl.Jaar(jaar))
totaal +=1;
break;
case 9:
totaal +=(1+2+3+4+5+6+7+8+9);
if(ctrl.Jaar(jaar))
totaal +=1;
break;
case 10:
totaal +=(1+2+3+4+5+6+7+8+9+10);
if(ctrl.Jaar(jaar))
totaal +=1;
break;
case 11:
totaal +=(1+2+3+4+5+6+7+8+9+10+11);
if(ctrl.Jaar(jaar))
totaal +=1;
break;
case 12:
totaal +=(1+2+3+4+5+6+7+8+9+10+11+12);
if(ctrl.Jaar(jaar))
totaal +=1;
break;
}
Why without DateTime? Even if you don't have it, I think it's easier to create one than do it yourself.
But if you want to do it yourself, you need an array of days for each month of the year, which you could sum up to previous month plus days of current month. And don't forget to add an extra day if it's a leap year and month > 2.
But if you want to do it yourself, you need an array of days for each month of the year, which you could sum up to previous month plus days of current month. And don't forget to add an extra day if it's a leap year and month > 2.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You could use the DateTime.DayOfYear property.
http://msdn.microsoft.com/en-us/library/system.datetime.dayofyear.aspx
/peter