473,396 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

list of days between two days

Hi. I want to make a list of days between two days.
How can I make it???
Thx.

Oct 19 '06 #1
7 2502

kirke wrote:
Hi. I want to make a list of days between two days.
How can I make it???
Thx.
Try:

<script type="text/javascript">
function showDays(f){
var selS = f.startDay;
var selE = f.endDay;
var days = [];
var i = 0;
while (i<7 && !selS.options[i].selected){
i++;
}
while (!selE.options[i].selected){
days.push(selE.options[i++].text);
i = i%7;
}
days.push(selE.options[i].text);
f.dayList.value = days.join('\n');
}
</script>
<form action="">
<div>
<label for="startDay">Start day:
<select name="startDay">
<option value="0" selected>Monday
<option value="1">Tuesday
<option value="2">Wednesday
<option value="3">Thursday
<option value="4">Friday
<option value="5">Saturday
<option value="6">Sunday
</select></label>
<label for="endDay">End day:
<select name="endDay">
<option value="0">Monday
<option value="1">Tuesday
<option value="2">Wednesday
<option value="3">Thursday
<option value="4">Friday
<option value="5">Saturday
<option value="6" selected>Sunday
</select></label>
<input type="button" value="Show day list"
onclick="showDays(this.form);">
<br>
<textarea readonly name="dayList" cols=10
rows=8></textarea>
</div>
</form>
--
Rob

Oct 19 '06 #2
Wow. yours are great.
However, I took a mistake. I mean date not day.SORRY.
Thus, start date is 10/19/2006 and end date is 10/31/2006 Then.
I want to make a list of 10/19/2006, 10/20/2006,....,10/30/2006,
10/31/2006 like this.
RobG wrote:
kirke wrote:
Hi. I want to make a list of days between two days.
How can I make it???
Thx.

Try:

<script type="text/javascript">
function showDays(f){
var selS = f.startDay;
var selE = f.endDay;
var days = [];
var i = 0;
while (i<7 && !selS.options[i].selected){
i++;
}
while (!selE.options[i].selected){
days.push(selE.options[i++].text);
i = i%7;
}
days.push(selE.options[i].text);
f.dayList.value = days.join('\n');
}
</script>
<form action="">
<div>
<label for="startDay">Start day:
<select name="startDay">
<option value="0" selected>Monday
<option value="1">Tuesday
<option value="2">Wednesday
<option value="3">Thursday
<option value="4">Friday
<option value="5">Saturday
<option value="6">Sunday
</select></label>
<label for="endDay">End day:
<select name="endDay">
<option value="0">Monday
<option value="1">Tuesday
<option value="2">Wednesday
<option value="3">Thursday
<option value="4">Friday
<option value="5">Saturday
<option value="6" selected>Sunday
</select></label>
<input type="button" value="Show day list"
onclick="showDays(this.form);">
<br>
<textarea readonly name="dayList" cols=10
rows=8></textarea>
</div>
</form>
--
Rob
Oct 19 '06 #3

kirke wrote:
Wow. yours are great.
However, I took a mistake. I mean date not day.SORRY.
Thus, start date is 10/19/2006 and end date is 10/31/2006 Then.
I want to make a list of 10/19/2006, 10/20/2006,....,10/30/2006,
10/31/2006 like this.
Try the Date object.

I.e.

var d = new Date(2006,9,19);
var d2 = new Date(2006,10,31);
var aDates = [];

do
{
aDates.push(d.toString());
d.setDate(d.getDate()+1);
}
while (d <= d2);

alert(aDates.join("\r\n"));

Regards

Julian

Oct 19 '06 #4

kirke wrote:
Wow. yours are great.
Please do not top post here, reply below trimmed quotes of what you are
replying to.
However, I took a mistake. I mean date not day.SORRY.
Thus, start date is 10/19/2006 and end date is 10/31/2006 Then.
I want to make a list of 10/19/2006, 10/20/2006,....,10/30/2006,
10/31/2006 like this.
And your attempt at this looks like... ? The date format you have
shown will likely be misunderstood by the vast majority of web users,
it is peculiar to only one country that I know of.

As a hint, get a date from some input elements. Validate the format
and that they generate a valid date, then use them to create new date
objects. Add one to the start date until you reach the end date,
collecting the dates along the way. Then write the list of dates
you've generated to some element - maybe a text area, span or p
element.

The script I posted gives you a start, but you will have to make
significant changes.

There are some date routines here:

<URL: http://www.merlyn.demon.co.uk/js-dates.htm >
--
Rob

Oct 19 '06 #5
Julian Turner wrote on 19 okt 2006 in comp.lang.javascript:
>
kirke wrote:
>Wow. yours are great.
However, I took a mistake. I mean date not day.SORRY.
Thus, start date is 10/19/2006 and end date is 10/31/2006 Then.
I want to make a list of 10/19/2006, 10/20/2006,....,10/30/2006,
10/31/2006 like this.

Try the Date object.

I.e.

var d = new Date(2006,9,19);
var d2 = new Date(2006,10,31);
var aDates = [];

do
{
aDates.push(d.toString());
d.setDate(d.getDate()+1);
}
while (d <= d2);

alert(aDates.join("\r\n"));
Good plan.
To keep up with the OQ, without using the localized version:

<script type='text/javascript'>

var d = new Date(2006,9,19);
var d2 = new Date(2006,10,31);

while (d <= d2) {
document.write(d.getYear() +
'/' + T(d.getMonth()+1) +
'/' + T(d.getDate()) + '<br>');
d.setDate(1 + d.getDate());
};

function T(x){
return (x < 10) ? "0" + x : x;
};

</script>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Oct 19 '06 #6
In message <Xn********************@194.109.133.242>, Thu, 19 Oct 2006
09:29:26, Evertjan. <ex**************@interxnl.netwrites
>To keep up with the OQ, without using the localized version:

<script type='text/javascript'>

var d = new Date(2006,9,19);

var d = new Date("2006/10/19");

is localised internationally, albeit with a non-ISO separator; it avoids
that irritating error of 1 in the month, which is liable to lead to
human error.
As well as the OP not having defined "day", he or she did not indicate
whether "between" means "between" or is intended to be inclusive.
Selection of while-do or do-while loop and of terminal condition should
fix that.

If the dates are supplied as Y M D numbers, rather than in an existing
Object, working in UTC would be faster.

If the dates are supplied as Objects, one must consider whether they may
have non-zero time components, and whether that matters.
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6 ©
<URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Oct 19 '06 #7

J R Stockton wrote:

[snip]
As well as the OP not having defined "day", he or she did not indicate
whether "between" means "between" or is intended to be inclusive.
Selection of while-do or do-while loop and of terminal condition should
fix that.
[snip]
The OP gave an example (in a second message):

"Thus, start date is 10/19/2006 and end date is 10/31/2006 Then.
I want to make a list of 10/19/2006, 10/20/2006,....,10/30/2006,
10/31/2006 like this. "

Regards

Julian Turner

Oct 20 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: .:DeVa:. \( \) | last post by:
Need function thath will list all days till today in current month... TNX..
1
by: Matt Karp | last post by:
DECLARE @varDate datetime DECLARE @varMonthDate datetime DECLARE @varYear datetime DECLARE @varFOM varchar(10) DECLARE @NumDaysInMonth as int select @varDate = '2/1/2004' select...
29
by: james | last post by:
I have a problem that at first glance seems not that hard to figure out. But, so far, the answer has escaped me. I have an old database file that has the date(s) stored in it as number of days. An...
8
by: Notgiven | last post by:
Say you have two dates, 2005-01-01 and 2005-01-24. I want to get a list or array or all the date between and including those two dates. I want to include this list in a query so I need it in a...
9
by: mistral | last post by:
Need help to remove list of days from date script. Need format "June 07, 2006" <SCRIPT LANGUAGE="JavaScript"> <!-- Begin // Get today's current date. var now = new Date();
4
by: eight02645999 | last post by:
hi i have a list (after reading from a file), say data = I wanted to insert a word after every 'a', and before every 'd'. so i use enumerate this list: for num,item in enumerate(data): if...
3
by: hharry | last post by:
Hello All, I'm writing an app to track file transfer activity. I have this enum to represent days of the week: Monday = 1 Tuesday = 2 Wednesday = 3 Thursday = 4
5
FishVal
by: FishVal | last post by:
IMHO, the following is not a how-to-do instruction to solve a particular problem but more a concept-proof stuff demonstrating possibilities of SQL. So, let us say the problem is to calculate...
8
by: wild wolf | last post by:
#include <iostream> int main() { int year,month,date,days,feb; cout<<"please input a date(eg. 2010 8 10)"; cin>>year>>month>>date; if((year%4==0&&year%100!=0)||year%400==0) feb=29; ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.