Calculate Friday dates only

D

David

Hi,

I need to display 3 fields with future dates (Fridays only) as table
column headers.
i.e. 16th Feb | 23rd Feb | 2nd March.

As each week passes, i.e. from the Saturday, the dates should move
accross 1, i.e. column 1 will update to 23rd Feb, Column 2 to 2nd
March and Column 3 to 9th March.

23rd Feb | 2nd March. | 9th March

I need this to work in IE & Firefox specifically.

Please can you help me work this out ?

Thanks


David
 
B

Bob Barrows [MVP]

David said:
Hi,

I need to display 3 fields with future dates (Fridays only) as table
column headers.
i.e. 16th Feb | 23rd Feb | 2nd March.

As each week passes, i.e. from the Saturday, the dates should move
accross 1, i.e. column 1 will update to 23rd Feb, Column 2 to 2nd
March and Column 3 to 9th March.

23rd Feb | 2nd March. | 9th March

I need this to work in IE & Firefox specifically.

Please can you help me work this out ?
It shouldn't be too hard. Assuming that if today were Friday, you would want
today's date in column one:

<%
dim today, nextfriday
today=date
nextfriday=today
do until weekday(nextfriday) = vbFriday
nextfriday = nextfriday + 1
loop
%>
<html>
<head>
<style>
th {background-color:gray;color:white}
</style>
</head>
<body>
<table>
<tr>
<th><%=nextfriday%></th>
<th><%=nextfriday + 7%></th>
<th><%=nextfriday + 14%></th>
</tr>
</table>
</body></html>
 
E

Evertjan.

Bob Barrows [MVP] wrote on 14 feb 2007 in
microsoft.public.inetserver.asp.general:
<%
dim today, nextfriday
today=date
nextfriday=today
do until weekday(nextfriday) = vbFriday
nextfriday = nextfriday + 1
loop
%>

Look, no loop:

today = date
temp = vbFriday - weekday(today)
if temp<0 then temp = temp + 7
nextfriday = dateadd("d", temp, today)
nextnextfriday = dateadd("ww", 1, nextfriday)
nextnextnextfriday = dateadd("ww", 2, nextfriday)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top