Click here to Skip to main content
15,896,497 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I am using Flex 3.

I want to know that how to get the current date of the next month.
I am facing the problem that if i choose the 31st march, 2011 from datefield, i can't get the result as 30th April, 2011. Same problem with the February Month of the leap year. So please give me help as early as possible.

I want that if i click on the 31st January, 2012 then i got result like 29th February, 2012.

My current code is:


txtdate.text = da.getDate().toString();
txtmonth.text = (da.getMonth()+1).toString();
txtyear.text = da.getFullYear().toString();

var tomorrow:Date = new Date(da.getFullYear(),(da.getMonth()+1) ,da.getDate());

Current output is like this

if i pass 17th March, 2011 then i got result 17th April, 2011.
if i pass 31st January, 2011 then i got result 3rd March, 2011.
Posted
Updated 9-Mar-11 19:53pm
v4

1 solution

This is not a programming question, in essence.

You first define "current date of the next month" and then immediately prove by yourself that it is not possible to find for every given date. Please realize that this is "I want it but I don't want it" and nothing else. Decide for yourself what you want.

You could easily make this question if you explained you idea not it its pure form which does not make sense, but in terms of desired UI behavior, for example. In this case you would hope to get the transformed idea with "restored sanity".

—SA
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 10-Mar-11 1:33am    
@sagarworld31,
I just wonder, it this your vote? Please answer.
--SA

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