[AccessD] Store all days between 2 dates / Type Mismatch

Gustav Brock gustav at cactus.dk
Thu Jan 29 07:19:48 CST 2004


Hi Sad

Never use strings for dates. Either change to datatype Date or
convert the strings to date/time values:

> intNumberOfDays = DateDiff("d", CDate(strStart), CDate(strEnd))

> ReDim arrDays(intNumberOfDays)
> for x = 0 to intNumberOfDays
>   arrDays(x) = DateAdd("d", x, CDate(strStart))
> next x

/gustav

> does anybody know how I can fill an array with the
> DATES between a startdate and an enddate? 

> I'm using datediff to calculate the no of days. I want
> to use this in a loop e.g.:
> Dim x as Integer
> Dim arrDays() as Variant
> Dim intNumberOfDays as Integer
> dim strStart as String
> Dim strEnd as String
> intNumberOfDays = DateDiff("d", strStart, strEnd)

> ReDim arrDays(intNumberOfDays)
> for x = 0 to intNumberOfDays
>   arrDays(x) = strStart + x
> next x

> I keep getting a Type Mismatch error. I also tried:
> arrDays(x) = CVAR(strStart + x)

> Any ideas?
> TIA.

> Sander

> Example:
> StartDate  EndDate    Return value(s)
> 21/01/2004 21/01/2004 21/01/2004
> 21/01/2004 22/01/2004 21/01/2004;22/01/2004
> 31/12/2003 02/01/2004 31/12/2003;01/01/2004;02/01/2004



More information about the AccessD mailing list