IT Community - Software Programming, Web Development and Technical Support

Show all the dates between two dates in YYYY-MM-DD format

This is a discussion on Show all the dates between two dates in YYYY-MM-DD format within the HTML, CSS and Javascript Coding Techniques forums, part of the Web Development category; Hi all... Can anyone tell me how can i show all the dates between two dates in YYYY-MM-DD ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > HTML, CSS and Javascript Coding Techniques

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 03-07-2008, 02:59 AM
itbarota itbarota is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 547
itbarota is on a distinguished road
Default Show all the dates between two dates in YYYY-MM-DD format

Hi all...



Can anyone tell me how can i show all the dates between two dates in YYYY-MM-DD format.


Thanks in advance...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-07-2008, 03:01 AM
Pvinothkumar Pvinothkumar is offline
D-Web Analyst
 
Join Date: Sep 2007
Posts: 237
Pvinothkumar is on a distinguished road
Default Re: Show all the dates between two dates in YYYY-MM-DD format

Hi all...


<script language="JavaScript">
function y2k(number) { return (number < 1000) ? number + 1900 : number; }
function padout(number) { return (number < 10) ? '0' + number : number; }

function showDates(startYear,startMonth,startDay,endYear,en dMonth,endDay) {
startDate = new Date(startYear,startMonth - 1,startDay);
endDate = new Date(endYear,endMonth - 1,endDay);

for (; {
// infinite loop
if (startDate > endDate) {
// break out of infinte loop and function
return;
}
document.write(y2k(startDate.getYear()) + '-' + padout(startDate.getMonth() + 1) + '-' + padout(startDate.getDate()) + '<br>');
// add a day to the date:
startDate = new Date(startDate.getTime() + 1*24*60*60*1000);
}
}

showDates(1999,12,1,1999,12,25);
</script>


Thanks...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-11-2008, 09:05 PM
GDevakii GDevakii is offline
D-Web Sr.Programmer
 
Join Date: Aug 2007
Posts: 138
GDevakii is on a distinguished road
Smile Re: Show all the dates between two dates in YYYY-MM-DD format

<SCRIPT LANGUAGE="JavaScript"><!--
function makeArray() {
this[0] = makeArray.arguments.length;
for (i = 0; i<makeArray.arguments.length; i++)
this[i+1] = makeArray.arguments[i];
}

var accumulate = new makeArray(0, 31, 59, 90,120,151,181,212,243,273,304,334);
var accumulateLY = new makeArray(0, 31, 60, 91,121,152,182,213,244,274,305,335);

function LeapYear(year) {
if ((year/4) != Math.floor(year/4)) return false;
if ((year/100) != Math.floor(year/100)) return true;
if ((year/400) != Math.floor(year/400)) return false;
return true;
}

function pad(number,length) {
var str = '' + number;
while (str.length < length)
str = '0' + str;
return str;
}

function getJulianDay(year,month,day) {
if (LeapYear(year))
return pad(day + accumulateLY[month],3);
else
return pad(day + accumulate[month],3);
}

function yy_to_ccyy(yy) {
// convert year in yy format to ccyy format
return (yy < 70) ? '20' + pad(yy,2) : '19' + yy;
}

var myDate = '000229'; // 29th February 2000

var year = yy_to_ccyy(myDate.substring(0,2) - 0);
var month = myDate.substring(2,4) - 0;
var day = myDate.substring(4,6) - 0;

var julianDate = '' + year + getJulianDay(year,month,day);

alert(julianDate);
//--></SCRIPT>
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparing two Dates Kirubhananth ASP and ASP.NET Programming 4 03-25-2008 09:46 PM
Validate a date to be in the format dd/mm/yyyy itbarota HTML, CSS and Javascript Coding Techniques 1 02-25-2008 09:21 PM
How can we know the number of days between two given dates using PHP? Sabari PHP Programming 5 09-27-2007 07:24 AM
Diff. between dates jegan PHP Programming 0 07-30-2007 03:02 AM
dates swoosh VB.NET Programming 0 03-15-2007 07:08 PM


All times are GMT -7. The time now is 11:13 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0