0

I wanted to check between 2 dates if it is a month or months after.

Example Input

startdate : 2020-01-31 enddate: 2020-02-12

If 1 month have passed or more from startdate to enddate then return true else false.

What I have tried

var now = new Date();
//current = new Date(now.getFullYear(), now.getMonth()+1, 1);
Community
  • 1
  • 1
  • What have you tried, and what exactly is the problem with it? – jonrsharpe Apr 22 '20 at 18:56
  • *"...and what exactly is the problem with it?"* Read [mre]. – jonrsharpe Apr 22 '20 at 18:57
  • 3
    _"So if input is 2020-04-23 then it will give output or date which is a month after. It will Check the day of the month."_ I don't know what this means. What is the desired output for this input? Why do you have END DATE "2020-01-31" at the end of your question? – JLRishe Apr 22 '20 at 18:59
  • I have updated the questio gentlemen. –  Apr 22 '20 at 19:04
  • It is still impossible to understand. sorry – Derviş Kayımbaşıoğlu Apr 22 '20 at 19:05
  • @DervişKayımbaşıoğlu , I have updated the question. –  Apr 22 '20 at 19:07
  • It's still help to know expected outputs. Since months are not all the same size, it's ambiguous understanding what exactly "1 month has passed" means. Do you mean if one date falls on a different calendar month than another? If a date falls on the next calendar month and has a day that's >= the previous day? What do you do about wrapping around from a longer month to a shorter month, like is 2020-02-29 considered to be a month after 2020-01-31 or not? – Jacob Apr 22 '20 at 19:09
  • @JLRishe, I have updated the question please check –  Apr 22 '20 at 19:09
  • Do you want to know if the month has gone up? Do you want to know if *at least* a month has passed between the dates? Do you want a bool result? Your wording suggests you want a bool, but your code example is producing dates. It's really not at all clear what you want. – GPW Apr 22 '20 at 19:09
  • yeah I want to know if at least a month has passed between the dates? , does not matter if the result is bool as long as I can check if a month has passed. –  Apr 22 '20 at 19:10
  • The title of the question and the body don't really match. The duplicate covers the question asked it the most recent revision of the question body, not the title. – Heretic Monkey Apr 22 '20 at 19:14
  • 1
    "Month" is not really a measure of time, unlike, say, 30 days. Before this can be solved, you need to have a clearer idea of the requirements. – Jacob Apr 22 '20 at 19:15

0 Answers0