displaying days between a date range (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


sentinel -> displaying days between a date range (2/28/2008 14:51:21)

Hey all,

I am creating a page that tracks vacation days. I have a form with 5 date fields on it. the first two are for choosing a beginning date and end date ( this is in case you take say 5 vacation days in a row).

The last 3 are for choosing any days that do not fall into the date range ( if chosen )

What I need to do somehow be able to present the user with all all the days they took off in a month. It is easy to create a results page showing the individual dates. How do I display the individual dates in the date range? Example... I need to show all days from 2008-01-01 to 2008-01-07.

2008-01-01
2008-01-02
2008-01-03
2008-01-04
2008-01-05
2008-01-06
2008-01-07

Any ideas?




rdouglass -> RE: displaying days between a date range (2/28/2008 15:56:14)

Just a quick stab:

...
FOR i = 0 TO datediff("d",startdate,enddate)
response.write(dateadd("d",i,startdate) & "<br>")
Next
...

something in that line perhaps? You see what I'm doing? Getting the number of days and using DateAdd inside a lopp?

That help any?

Oh Yeah, you'll probably want to use FormatDateTime with that.




sentinel -> RE: displaying days between a date range (2/28/2008 16:08:20)

I did a test with
<%
startdate=2007-01-01
enddate=2007-01-01
FOR i = 0 TO datediff("d",startdate,enddate)
response.write(dateadd("d",i,startdate) & "<br>")
Next

%>

and it returned

6/27/1905

If I changed it to :
<%
startdate=2007-01-01
enddate=2007-01-09
FOR i = 0 TO datediff("d",startdate,enddate)
response.write(dateadd("d",i,startdate) & "<br>")
Next

%>

It returns a blank page.

Any ideas?





rdouglass -> RE: displaying days between a date range (2/28/2008 16:47:20)

quote:

startdate=2007-01-01
enddate=2007-01-01


Sorry, my example would require a different date format as in:

startdate="2007-01-01"
enddate="2007-01-01 "

But those would probably not be in the proper format. Something like this might be better for your specific scenario:

startdate="2007-01-01"
enddate="2007-01-01"

startdate = cdate(mid(startdate,6,2) & "/" & right(startdate,2) & "/" & left(startdate,4))
enddate = cdate(mid(enddate,6,2) & "/" &right(enddate,2) & "/" & left(enddate,4))

Something like that to put it in a MM/DD/YYYY format. That any help?




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
6.054688E-02