Identifying dates to specific months

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • charindal
    New Member
    • Dec 2009
    • 17

    Identifying dates to specific months

    I would like some help on how best to implement this. I have a form which accepts a project's name and asks for the start day and end day. Along with this information, there is also a cost involved which is calculated on a monthly basis. say for example the start date is 15 july and end date is 25 september. it should be able to figure out that from 15 july to 31st july, they are days for july. then identify 31 days for aug,and as well identify 25 days for september. This information is necessary since the cost factor is dependent on number of days per month. My question is how do you determine number of days for each specific month......NB if it was the same month that would be easy since you just use the timespan day function. however the trick comes when months over lap, i.e. identifying which days goes to which month.
  • BlueVoodoo
    New Member
    • Jul 2010
    • 5

    #2
    You mean like DateTime.DaysIn Month(year, month)??

    Example (use for loop though)

    int daysJuly = DateTime.DaysIn Month(2010, 07) - 15;
    int daysAug = DateTime.DaysIn Month(2010, 08);
    int daysSep = 25;

    int totalDays = daysJuly + daysAug + daysSep;

    Comment

    • charindal
      New Member
      • Dec 2009
      • 17

      #3
      thank you

      yah i think i got the logic from your example...the trick is to get the start day then subtract it like what you showed me, then continue the process until i get to the last day which i will just take the day as the number of days for that month... thank you

      Comment

      Working...