-Log in
-Register (free)


-RSS Feeds
-New MyDesk Module
-Update to Profile

Alternate color for RS looping with For Next
Northwind / ASP - Nested select
ASP SQL Injection




 Forums / Back to page 1 /

Help with Array Dates
frenzy | Posted 12:30am 30. December 2002 Server Time |

All,

I'm trying to list valid dates between "12/1/02" to "12/31/02" by using an array. Here is my code, but it only displays one date. Array experts please help! Thank you in advance. HAPPY NEW YEARS!

<%
dim logdate()
dim i
for i = 0 to datediff("d","12/1/02","12/31/02")
   redim dates(i)
   dates(i) = i
   x = "12/1/02"
   response.write  dateadd("d",1,x) & "<br>"
next
%>
frenzy | Posted 12:43am 30. December 2002 Server Time |

I came up with this and it works, but wondering if it is the correct way. Should this code be re-written differently? Thank you in advance.

<%
dim logdate()
dim i
dim x
dim add
add = 1
x = "12/1/02"
for i = 0 to datediff("d","12/1/02","12/5/02")
   response.write dateadd("d",1,x) & "<br>"
   x = dateadd("d",1,x)
next
%>
crazy7th | Posted 8:47pm 17. April 2011 Server Time |

Hello Frenzy,

in your code, "12/1/02" didnt show in result,
also the result show "12/6/02"

so, this is a little correct from your code :
<%
        dim logdate()
        dim i
        dim x
        dim add
        add = 1
        
        x = "2/25/2012"
        y = "3/5/2012"
        
        response.write (x) & "<br>"
        
        for i = 1 to datediff("d",x,y)
           response.write dateadd("d",1,x) & "<br>"
           x = dateadd("d",1,x)
        next
%>
1
Show all replies to 'Help with Array Dates'
This post have been closed for new replies



| Info |
© Copyright 1997-2013 Alexander Haneng