?
Solved

all the dates of the current month

Posted on 2003-12-05
5
Medium Priority
?
215 Views
Last Modified: 2010-04-06
how can i diplay all the dates of the current month excluding saturdays and sundays and stop
from the current date.
sample

today is 11/27/2003

it will display all the dates of the current month
11/3/2003
11/4/2003
11/5/2003
11/6/2003
11/7/2003
11/10/2003
11/11/2003

etc..

11/24/2003
11/25/2003
11/26/2003
it will stop here because today is 11/27/2003.

pls. help

thanks!
0
Comment
Question by:liway
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 10

Expert Comment

by:ADSaunders
ID: 9881305
Hi liway,
VBScript:
Dim d, m, y
m = month(now)
y = year(now)
For i = 1 To day(now)
      msgbox cdate(cstr(m) & "/" & cstr(i) & "/" & cstr(y))
Next


Regards .. Alan
0
 
LVL 15

Accepted Solution

by:
Ralf Klatt earned 200 total points
ID: 9881933
Hi,

This one will do what you wanted -> leave saturday and sunday out!

Dim d, m, y, i, j, strg
m = Month(Now)
y = Year(Now)
For i = 1 To Day(Now)
    If Weekday(CDate(CStr(m) & "/" & CStr(i) & "/" & CStr(y))) <> 1 And Weekday(CDate(CStr(m) & "/" & CStr(i) & "/" & CStr(y))) <> 7 Then
        strg = strg & CDate(CStr(m) & "/" & CStr(i) & "/" & CStr(y)) & vbCrLf
     End If
Next
MsgBox strg


Best regards, Raisor
0
 
LVL 10

Expert Comment

by:ADSaunders
ID: 9882070
>> excluding saturdays and sundays (Missed this bit)
VBScript:
Dim d, m, y, dt
m = month(now)
y = year(now)
For i = 1 To day(now)
     dt = cdate(cstr(m) & "/" & cstr(i) & "/" & cstr(y))
     if WeekDay(dt) <> 1 and day(dt) <> 2 then msgbox(dt)
Next


Regards .. Alan
0
 
LVL 10

Expert Comment

by:Bustarooms
ID: 9882450
this is cross browser

<html>
<head>
<script language="Javascript">
function writeDates(){
var today = new Date();
today.setHours(0,0,0,0);

currentMonth = today.getMonth() + 1;
currentYear = today.getFullYear();

document.write('today is ' + currentMonth + '/' + today.getDate() + '/' + currentYear);
document.write('<br><br>');

  for(i=1;i<32;i++){
     var tempDate = new Date(currentMonth + '/' + i + '/' + currentYear);
   if(tempDate.getTime() > today.getTime())
       break;

     var tempMonth = tempDate.getMonth() + 1;
     var tempDay = tempDate.getDate()
     var tempYear = tempDate.getFullYear();

     if(tempDate.getDay() != 0 && tempDate.getDay() != 6 && tempMonth == currentMonth){
       document.write(tempMonth + '/' + tempDay + '/' + tempYear + '<br>')
     }
  }
}
</script>
</head>
<body>
<script>writeDates();</script>
</body>
</html>
0
 
LVL 10

Expert Comment

by:Bustarooms
ID: 9882460
change this line
   if(tempDate.getTime() > today.getTime())


to this if you don't want the current date written on the last line

   if(tempDate.getTime() >= today.getTime())
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question