Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 2 dates : Start date and end date and cash flows based on those dates depending on user input.

If a person doesn't want to enter start date, it will take the end date and print the cash flows.
Example: End Day = 5th of the month, then start date is always (end date + 1 day) i.e. 6th of the month.

Right now my code is working however, if it's the end of the month or 31st, then it's printing 32nd for start date which is incorrect. It should be the 1st since it's the new month. How do i use that condition inside my code? Any help will be greatly appreciated. Thank you.

What I have tried:

if (startDate == null) {
  sDay = endDate.getUTCDate()+1;
}
Posted
Updated 1-Jun-18 5:18am

1 solution

 
Share this answer
 
Comments
Member 13289364 1-Jun-18 11:25am    
I did. This is if a user enters end date only and it can be any input. It works for all except when it's end of the month. It won't read the next months date.
Richard MacCutchan 1-Jun-18 12:43pm    
According to the documentation, setutcdate will adjust values above 30 or 31 as appropriate. I just tried a sample and it worked.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900