Calculate Friday dates only

Discussion in 'ASP General' started by David, Feb 14, 2007.

  1. David

    David Guest

    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
     
    David, Feb 14, 2007
    #1
    1. Advertising

  2. David wrote:
    > 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>


    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Feb 14, 2007
    #2
    1. Advertising

  3. David

    Evertjan. Guest

    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)


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Feb 14, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Lozzi

    Dates dates dates dates... SQL and ASP.NET

    David Lozzi, Sep 29, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    867
    Rob Schieber
    Sep 30, 2005
  2. Tom
    Replies:
    6
    Views:
    566
    Diego Martins
    Mar 16, 2006
  3. Alexandre Jaquet

    calculate day, hour , sec between dates

    Alexandre Jaquet, May 22, 2007, in forum: Java
    Replies:
    13
    Views:
    765
    Roedy Green
    May 28, 2007
  4. Alexandre Jaquet

    calculate day, hour , sec between dates

    Alexandre Jaquet, May 22, 2007, in forum: Java
    Replies:
    0
    Views:
    282
    Alexandre Jaquet
    May 22, 2007
  5. PW

    Dates! Dates! Dates!

    PW, Aug 7, 2004, in forum: ASP General
    Replies:
    4
    Views:
    197
    Mark Schupp
    Aug 9, 2004
Loading...

Share This Page