Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to get the Dates in-between two Dates

 
Anamika Gubba
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am struggling to calculate the dates in between two Dates. Can any one tell me how to do this?

For Example say

Date toDate = 2006-05-20
Date fromDate = 2006-05-25

I want to calculate in-between days. I.e. I want to get the result as

2006-05-21
2006-05-22
2006-05-23
2006-05-24
2006-05-25

Please let me know how to do this.

Thanks in advance,
Anamika
 
Scott Johnson
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's one way:

toDate = 2006-05-20
fromDate = 2006-05-25

add 1 day to toDate

while toDate is less than or equal to fromDate

print toDate

add 1 day to toDate

loop
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!