Listing dates w/ DateDiff

# Thread: Listing dates w/ DateDiff

1. Member
Join Date
Dec 1969
Posts
33

## Listing dates w/ DateDiff

I&#039;m trying to determine the number of days, weeks, months between two dates and list each day, week, month in chronological order along with the total number of records submitted on each. I used the DateDiff function to determine the number of each between the two dates, but is there a way to list all the dates that fall between the two dates?<BR><BR>Please advice. Thanks!

2. God
Senior Member
Join Date
Dec 1969
Posts
18,177

## RE: Listing dates w/ DateDiff

sSQL = "SELECT FieldA " & _<BR> "FROM TheTable "<BR> "WHERE TheDate &#062;= #1/1/2001# AND TheDate &#060;= #1/1/2001#"<BR><BR>Or, in SQL Server:<BR>sSQL = "SELECT FieldA " & _<BR> "FROM TheTable "<BR> "WHERE TheDate &#062;= &#039;1/1/2001&#039; AND TheDate &#060;= &#039;1/1/2001&#039;"

3. Member
Join Date
Dec 1969
Posts
33

## RE: Listing dates w/ DateDiff

God,<BR>I can pull the Select, but it&#039;s the listing of the dates that fall between that&#039;s the problem.<BR><BR>Does heaven have a solution?

4. God
Senior Member
Join Date
Dec 1969
Posts
18,177

## Oh.. ok, I read that wrong.

Dim dtStart, dtEnd, dtLoop<BR> dtStart = #1/1/2001#<BR> dtEnd = #2/1/2001#<BR><BR> dtLoop = dtStart<BR> While (dtLoop &#060;= dtEnd)<BR> Response.Write dtLoop & "&#060;br /&#062;"<BR><BR> dtLoop = DateAdd("d", dtLoop, 1)<BR> Wend

5. Member
Join Date
Dec 1969
Posts
33

## RE: Listing dates w/ DateDiff

What I mean is, I need to list the dates that fall between the two dates individually along with the total # of records submitted on that day, week, month.<BR><BR>EX.<BR><BR>05/01/02 -- 10 records<BR>05/02/02 -- 8 records<BR>etc.

6. Member
Join Date
Dec 1969
Posts
33

## RE: Oh.. ok, I read that wrong.

It works! Thanks a bundle. To do the same for weeks and months instead of days, do I need to just change the DateAdd interval to "w" or "m"?

7. God
Senior Member
Join Date
Dec 1969
Posts
18,177