This topic is locked

How to calculate a sequence of dates

10/12/2006 2:00:16 AM
ASPRunnerPro General questions
J
jlgouget author

Hi everybody,
I would like to determine a sequence of dates from a date 01(using datepicker) to a date 02 (using datepicker) and save these dates in a third field of the database.
Example :

date 01 = 01/10/2006 (datepicker)

date 02 = 04/10/2006 (datepicker)

DatesResult = 01/10/2006,02/10/2006,03/10/2006,04/10/2006
It's for a renting application.
With many thanks.
Friendly yours
Jean-Louis

Alexey admin 10/16/2006

Jean-Louis,
here is the sample code you can use in Before Edit and Before Add events:

dt1 = CDate(values("date 01"))

dt2 = CDate(values("date 02"))

out=""

while dt1<=dt2

out=out & CStr(dt1) & ","

dt1 = DateAdd("d", 1, dt1)

wend

values("field 03") = out



where "date 01", "date 02" and "field 03" are your actual field names.