Click to See Complete Forum and Search --> : how to create news archive


genius
07-26-2005, 05:02 AM
in this news archive i want create a dropdown box for one month date from current date.suppose today date is 7/26/05.now i want to populate this box with values like 6/25/05-------------7/25/05.means one month back of current date.when user select any of date of this box then corresponding category of news will display.

this is only over view.i want basic idea how to perform such task.......

thanx

buntine
07-26-2005, 05:16 AM
Ok. Should be fairly straight-forward.

First of all, you need to get the date exactly one month ago.

Dim dteLastMonth: dteLastMonth = DateAdd("m", -1, Date())

Then get the difference in days from then to now, loop through that number of times, adding one day at a time.

Dim intDiff, i, dteIncrement
intDiff = DateDiff("d", dteLastMonth, Date())

Response.Write "<select name=""dteChooser"">"
For i = 0 To intDiff
dteIncrement = DateAdd("d", i, dteLastMonth)
Response.Write "<option value=""" & dteIncrement & """>" & dteIncrement & "</option>" & VbCrLf
Next
Response.Write "</select>"

Make sense?

Regards.