# Thread: array sortimg (data and time array)

1. Registered User
Join Date
Dec 2011
Posts
27

## Unanswered: array sortimg (data and time array)

i need to sort some arrays in the basis of date and time , i wrote some code.but it does not work properly.please help me

For i = 1 to Rec_count

For j = i+1 to Rec_count

if(CaldTime( i ) < CaldTime( j )) then

temp = CaldTime(j)
CaldTime( j ) = CaldTime( i )
CaldTime( i ) = temp

End If
Next
Next

2. Registered User
Join Date
Dec 2011
Posts
27
I solved this one on my own. Probably far from the most elegant, but this is what I did:

For i = 1 to Rec_count
For j = i to Rec_count
if CaldTime( i ) <> "" and CaldTime( j ) <> "" then

if( DateDiff("s",DateValue(CaldTime( i )) &" "& (FormatDateTime(CaldTime(i ),4)), DateValue(CaldTime( j)) &" "& (FormatDateTime(CaldTime(j ),4))) > 0) then

temp = CaldTime(j)
CaldTime( j ) = CaldTime( i )
CaldTime( i ) = temp

End If

End If

Next
Next

3. www.gvee.co.uk
Join Date
Jan 2007
Location
UK
Posts
11,445
I wrote something in Access a long time ago that does something like this.

http://www.dbforums.com/microsoft-ac...alue-list.html

Hope this helps

4. Registered User
Join Date
Dec 2011
Posts
27
Thanku dear gvee